From patchwork Sat Mar 23 11:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1915129 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IzTXhVcc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V1xLR1n8Yz1yXr for ; Sat, 23 Mar 2024 22:10:05 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F238A385841C for ; Sat, 23 Mar 2024 11:10:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 B96633858C53 for ; Sat, 23 Mar 2024 11:09:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B96633858C53 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 B96633858C53 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=1711192180; cv=none; b=j4l/exgI0PtGeOVpSCOP07OsV25Mv5hpHpJHjdzctL80/7OihnpC3sikEMleBssFaEb021o9uhBS2bFrOMxJ0Af1rMAGZNPe/M3T05zKXbZMt7huIOJu9Rm6XNE06un2WoSlxSuVJcLw/Xy5/5b9/HNjiKpw4s7vt9mx3Di9V6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711192180; c=relaxed/simple; bh=DFIhFynw550O1TqWcbgyBVpe3mWlr4IKmc/BopjJAec=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=D4Ko5B4QOjuoiUYBXxLS6h+ZOxQnqqZhuiXErN0CFQrOR1ONjWuHmXQkCDM3BnBSoSp1w+nOx/VDgt2lv8J8qtFXe28NVhJ7bjygDmg+3pJZL4mZ7YHAgvARKhfrTuczHkciSNgbxOOjGj4pWqDIqErJatua3dOp30YQajIXL7k= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711192178; 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=gTEtzGKTrSzDYnJ5LN5w2e/Jt4jEEPZw1HCZyRW1uCQ=; b=IzTXhVccJcC8uc9MSgTESF8BWAg8wDMjqdLJnE6PBb1OWg32KlzL5w8itKaCFoI3y4DfGS evDH0jZsuk8P5ToJiSucTkyGhjBlKk9iar+DIYIWItb7P+g/iUZzhAEaJRHRVP+XoIZ/CP J9bqrX9dAf5MDSTAhWYoJuNWDEzzuKI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-391-5z0yTDHLMLmt5klvL3UTNQ-1; Sat, 23 Mar 2024 07:09:34 -0400 X-MC-Unique: 5z0yTDHLMLmt5klvL3UTNQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 6FC993C02792; Sat, 23 Mar 2024 11:09:34 +0000 (UTC) Received: from localhost (unknown [10.42.28.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C4AD1121337; Sat, 23 Mar 2024 11:09:34 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use std::type_identity_t in as per LWG 3950 [PR114400] Date: Sat, 23 Mar 2024 11:09:10 +0000 Message-ID: <20240323110929.426054-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested aarch64-linux. Pushed to trunk. -- >8 -- The difference between __type_identity_t and std::type_identity_t is observable, as demonstrated in the PR. Nobody in LWG seems to think this an example we should really care about, but it seems easy and harmless to change this. libstdc++-v3/ChangeLog: PR libstdc++/114400 * include/std/string_view (operator==): Use std::type_identity_t in C++20 instead of our own __type_identity_t. --- libstdc++-v3/include/std/string_view | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index e30a9c1768e..a7c5a126461 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -602,15 +602,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // deduction and the other argument gets implicitly converted to the deduced // type (see N3766). +#if __cpp_lib_three_way_comparison template [[nodiscard]] constexpr bool operator==(basic_string_view<_CharT, _Traits> __x, - __type_identity_t> __y) + type_identity_t> __y) noexcept { return __x.size() == __y.size() && __x.compare(__y) == 0; } -#if __cpp_lib_three_way_comparison template [[nodiscard]] constexpr auto @@ -620,6 +620,14 @@ _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, + __type_identity_t> __y) + noexcept + { return __x.size() == __y.size() && __x.compare(__y) == 0; } + template [[nodiscard]] constexpr bool