From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id A1EE9385840B for ; Wed, 13 Oct 2021 20:19:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A1EE9385840B Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-76-vJTSL9NFPPS9wuuSo-lCZA-1; Wed, 13 Oct 2021 16:19:44 -0400 X-MC-Unique: vJTSL9NFPPS9wuuSo-lCZA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 554705128; Wed, 13 Oct 2021 20:19:43 +0000 (UTC) Received: from localhost (unknown [10.33.37.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A2BD19729; Wed, 13 Oct 2021 20:19:42 +0000 (UTC) Date: Wed, 13 Oct 2021 21:19:41 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [committed] libstdc++: Refactor filesystem::path encoding conversions Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Oct 2021 20:19:48 -0000 On 13/10/21 20:41 +0100, Jonathan Wakely wrote: >Adjust the __detail::__effective_range overloads so they always return a >string or string view using std::char_traits, because we don't care >about the traits of an incoming string. > >Use std::contiguous_iterator in the __effective_range(const Source&) >overload, to allow returning a basic_string_view in more cases. For the >non-contiguous cases in both __effective_range and __string_from_range, >return a std::string instead of std::u8string when the value type of the >range is char8_t. These changes avoid unnecessary basic_string >temporaries. [...] > template > inline auto > __string_from_range(_InputIterator __first, _InputIterator __last) > { > using _EcharT > = typename std::iterator_traits<_InputIterator>::value_type; >- static_assert(__is_encoded_char<_EcharT>); >+ static_assert(__is_encoded_char<_EcharT>); // C++17 [fs.req]/3 > >-#if __cpp_lib_concepts >- constexpr bool __contiguous = std::contiguous_iterator<_InputIterator>; >-#else >- constexpr bool __contiguous >- = is_pointer_v; >-#endif >- if constexpr (__contiguous) >+ if constexpr (__is_contiguous<_InputIterator>) Oops, this pessimiszes construction from string::iterator and vector::iterator in C++17 mode, because the new __is_contiguous variable template just uses is_pointer_v, without the __niter_base call that unwraps a __normal_iterator. That means that we now create a basic_string temporary where we previously jsut returned a basic_string_view. I am testing a fix.