From patchwork Tue Nov 15 19:32:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 82402 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp1897400obn; Tue, 15 Nov 2016 11:33:05 -0800 (PST) X-Received: by 10.98.63.1 with SMTP id m1mr49165702pfa.31.1479238385251; Tue, 15 Nov 2016 11:33:05 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v26si1144251pge.21.2016.11.15.11.33.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2016 11:33:05 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441540-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-441540-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441540-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=feZ0k1wcm6chOcmIKVYVZHPdUugfDJ GgU65W0EiAYo7d/aruc/CojBy/TC4IKizxCtRqwBjgftu4zB+uktrVAtHWo2lI0D EGQN0STeWQL0pq8mUjKBIP2XurmK/ch5D0xTG7eeuq3ldwHyYAh1SQoJPZK8zhXd kw5NkAscxGNUI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=Df/omv5F/F3285cd6ynRVyRh2is=; b=Gv5j 3T6yBNWEy8X1IzPwO2Z6NRGD1taKPAWVGESteEskO7F+/21J+P5XGxSjCZLJ5c2e NMHOxGQU4S0APwPp36HmvlI83myXDwmFkG9UBvSYhnN8IGrQQUQm2jmy4fUpb0ug Y2mo1hGjKI4FDk6RjKRFBCWn2eBp6AwRUEdgXu8= Received: (qmail 27527 invoked by alias); 15 Nov 2016 19:32:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27505 invoked by uid 89); 15 Nov 2016 19:32:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1256, 6, 12566, Hx-languages-length:2761, 5856 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Nov 2016 19:32:48 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 689BF6DDBB; Tue, 15 Nov 2016 19:32:47 +0000 (UTC) Received: from localhost (ovpn-116-110.ams2.redhat.com [10.36.116.110]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAFJWkFI007075; Tue, 15 Nov 2016 14:32:47 -0500 Date: Tue, 15 Nov 2016 19:32:46 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Add std::string constructor for substring of string_view (LWG 2742) Message-ID: <20161115193246.GM3145@redhat.com> References: <20161115143349.GG3145@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161115143349.GG3145@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.1 (2016-10-04) On 15/11/16 14:33 +0000, Jonathan Wakely wrote: >This is another issue resolution for C++17 features that was approved >at the recent meeting. I think this resolution is wrong too, but in >this case the fix is obvious so I've gone ahead and done it. > > * doc/xml/manual/intro.xml: Document LWG 2742 status. > * doc/html/*: Regenerate. > * include/bits/basic_string.h > (basic_string(const T&, size_type, size_type, const Allocator&)): Add > constructor for substring of basic_string_view, as per LWG 2742 but > with additional constraint to fix ambiguity. > * testsuite/21_strings/basic_string/cons/char/9.cc: New test. > * testsuite/21_strings/basic_string/cons/wchar_t/9.cc: New test. > >Tested powerpc64le-linux, comitted to trunk. I forgot I already added an convenience alias template for checking the condition in this patch. Tested powerpc64le-linux, comitted to trunk. commit f7852de7c77f0d9cc8520d10549da0652e334dc7 Author: Jonathan Wakely Date: Tue Nov 15 18:55:35 2016 +0000 Use existing helper for new std::string constructor * include/bits/basic_string.h: Reuse _If_sv alias template for new constructor. diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 943e88d..9af7bfb 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -585,6 +585,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 { _M_construct(__beg, __end); } #if __cplusplus > 201402L + template + using _If_sv = enable_if_t< + __and_, + __not_>>::value, + _Res>; + /** * @brief Construct string from a substring of a string_view. * @param __t Source string view. @@ -592,9 +598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @param __n The number of characters to copy from __t. * @param __a Allocator to use. */ - template, - __not_>>> + template> basic_string(const _Tp& __t, size_type __pos, size_type __n, const _Alloc& __a = _Alloc()) : basic_string(__sv_type(__t).substr(__pos, __n), __a) { } @@ -1252,12 +1256,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 append(__sv_type __sv) { return this->append(__sv.data(), __sv.size()); } - template - using _If_sv = enable_if_t< - __and_, - __not_>>::value, - _Res>; - /** * @brief Append a range of characters from a string_view. * @param __sv The string_view to be appended from.