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.129.124]) by sourceware.org (Postfix) with ESMTPS id 55D383894C0A for ; Sat, 11 Nov 2023 00:45:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55D383894C0A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 55D383894C0A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699663520; cv=none; b=vWQG8aWrH66u80FBj/c4zOns2BxRPtlTgmSDkqyPJCdlsL+Tgua3ZaRP7JBl4TVVbVVuE7QWDVoKRaq3AfK1xmZuisLmDPVU6Y0Tar+m2jdG1UyNAZNeFHOE/0TYb4vQhQlyq0loLJZsPIFd0Xnh5zzJaMu8MqJY0o88Z8x9Dsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699663520; c=relaxed/simple; bh=XtRwmwMDF3Wnyjpd4Ok3AL/WtsgR6INGHWVRuUB359w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kAGUjUzwp44aEWeR+zZrqbDTZTAg29uP4XfmrrhLcnGCh5L1oh4YEdidqedduRVUfwJzyaCmbGoURoNAHTclfmOlVBpeliVCNPOL7a/zNERLNOuD09xGEEfFNysf9YLtfQmaGFNrEvReDViYrtXNyp6qXKA1VhiXoOPlFPSnKus= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699663519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+jvsUw9BpXMBjBXMsAqPdfTyDoLCR/P7HOpVShHT8+o=; b=MKkZipEFuDR+Q25wBITbL5kVuNJPW1YO8zc8WjPCcSwkfq96oV4bQj6ichi78hcgTqXCoc YKlptq0yNTnJ082oDbFw56RcL08UKjyUdFq1E45ySArdAC5hDuQnAQ+r4ISdq6m2s78NHH ZllhOAahs9or9DRGO3oqhh21d3q4TiY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-H-YmXKKRNfe__lTE5BaxFw-1; Fri, 10 Nov 2023 19:45:16 -0500 X-MC-Unique: H-YmXKKRNfe__lTE5BaxFw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B0EC7101A529; Sat, 11 Nov 2023 00:45:15 +0000 (UTC) Received: from localhost (unknown [10.42.28.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BFD6502A; Sat, 11 Nov 2023 00:45:15 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Simplify std::string_view comparisons (LWG 3950) Date: Sat, 11 Nov 2023 00:45:11 +0000 Message-ID: <20231111004515.78648-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- LWG 3950 points out that the comparisons of std::basic_string_view can be simplified to just a single overload of operator== and a single overload of operator<=>. Those overloads work fine for homogeneous comparisons of two string view objects. libstdc++-v3/ChangeLog: * include/std/string_view (operator==, operator<=>): Remove redundant overloads (LWG 3950). --- libstdc++-v3/include/std/string_view | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 9deae25f712..cf288ed3a36 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -602,13 +602,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // deduction and the other argument gets implicitly converted to the deduced // type (see N3766). - template - [[nodiscard]] - constexpr bool - operator==(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.size() == __y.size() && __x.compare(__y) == 0; } - template [[nodiscard]] constexpr bool @@ -618,14 +611,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __x.size() == __y.size() && __x.compare(__y) == 0; } #if __cpp_lib_three_way_comparison - template - [[nodiscard]] - constexpr auto - operator<=>(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0)) - { return __detail::__char_traits_cmp_cat<_Traits>(__x.compare(__y)); } - template [[nodiscard]] constexpr auto @@ -635,6 +620,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0)) { return __detail::__char_traits_cmp_cat<_Traits>(__x.compare(__y)); } #else + template + [[nodiscard]] + constexpr bool + operator==(basic_string_view<_CharT, _Traits> __x, + basic_string_view<_CharT, _Traits> __y) noexcept + { return __x.size() == __y.size() && __x.compare(__y) == 0; } + template [[nodiscard]] constexpr bool -- 2.41.0