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 5A013389839C for ; Sat, 11 Nov 2023 00:45:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A013389839C 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 5A013389839C 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=1699663519; cv=none; b=nUlpZDRnz7VUic5vpoMeUFk/S635Vcbo+K/aGTKBwL38Sg23PsNGj0FidfX7pCPo3NMbWXtWrIlTH5Z+/VOeF8WZykozC/xELl1hDzCyWVivvfcZqDcnpZHhqR3+JzUF3oE+oQPH7dpBgnilpZaLANyoBkz1uH8tQGFLRLRLiGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699663519; c=relaxed/simple; bh=XtRwmwMDF3Wnyjpd4Ok3AL/WtsgR6INGHWVRuUB359w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WEmZBQsglcGY41By2o9Nq247EklnvSd1vTYTCJoOhhAUjEjBnYVOP8v2ZlLid9tzoAnIDWOxrDaiLFiyXswz/gm7Ffjl1NocO7WThjsTtdcO/Nx13kg18kKFKAQlNoExmVgNimc7uay6HxkZIKUa7a0254hHVQlbVQfyF1e92Rc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699663517; 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=bsKgyNFlS5cpeEC+O94Lv6yWR7z5L9gBxF3ugzLSZ0DjmUFtxJEO6BjE4Eu5PF0vfh60QS qZFFB1TqwmrN4/uAxg7MT6iNl5gqT/wARe3Q2s4scX9kFPLo34MALM9wExmfuxvgDut814 78VK5hqdluSbmmJcn7dtiJq3T3cvCNA= 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=ham 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