From patchwork Fri Nov 8 14:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 2008488 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=D+SnxYKQ; 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 4XlM8y5nx6z1xxq for ; Sat, 9 Nov 2024 01:42:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4897385843D for ; Fri, 8 Nov 2024 14:42:06 +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.133.124]) by sourceware.org (Postfix) with ESMTP id E2E853858D21 for ; Fri, 8 Nov 2024 14:41:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E2E853858D21 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 E2E853858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731076899; cv=none; b=jt1vNO/98gh5M+rlJCCc+h+6BurXyAZze0Lw9A9Boh6dPChTjiuMgs+ha0Qs/NlhN1Y4ZGiooNzvpHQtSEK9WhEsJP/6cV/zgyHXMeU9WiAkgRaBrOeCUSwJ0HbwGJRjBWiuqlpHAeVr8wAPcig83SBcKCixP8NJagS1Whh2U+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731076899; c=relaxed/simple; bh=NEeRHl2Bh+5zxX7ljTl76M6gatn2Lp7Jtu1YszwChis=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wY2wslQX10fXY/EcKMX2UyEVh6E6L+AF8NkZyu7cYWE+ksbJguBsd2Xf4yOBM1jrBCTxG6f7OKyaJU0BC4akEAzO+wn851rXbFvqgIcW9YOQTwPPjlZgVO1T7CsDSXTF4Ve1wtV2fI8TIy7KTHuxjPzPRqHDXnQX63I0R02RL5E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731076897; 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=kKVxRMuge9NyPgNOJ8gYTB5ENqd7Jj5BTiKk68xUGwM=; b=D+SnxYKQy5k2k2nrdtRNFhI2gvlrd2zRRvOJLA6pDTpirI42PUo7Lwwn5xAVYTf8PjuDcl IuVO1msVFRPZCYeJRhSAhlngewqyyIc07K/zLcQenNc79BbaYyMP4gxVGWht6wY3h6IktE ZMPjfFDpQj2istouj4BgN9P0/Z9tJ6M= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-bPC6UADdOkCYlorEKQW95A-1; Fri, 08 Nov 2024 09:41:36 -0500 X-MC-Unique: bPC6UADdOkCYlorEKQW95A-1 X-Mimecast-MFC-AGG-ID: bPC6UADdOkCYlorEKQW95A Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 519DA19560B1; Fri, 8 Nov 2024 14:41:34 +0000 (UTC) Received: from localhost (unknown [10.22.64.104]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8D600195E480; Fri, 8 Nov 2024 14:41:33 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Do not define _Insert_base::try_emplace before C++17 Date: Fri, 8 Nov 2024 14:41:11 +0000 Message-ID: <20241108144132.796586-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3Dl1PHR-OhuB4MnsEB3HjnvSm3AAdaYZ30RKfZ4V9UA_1731076895 X-Mimecast-Originator: redhat.com 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 This is not a reserved name in C++11 and C++14, so must not be defined. Also use the appropriate feature test macros for the try_emplace members of the Debug Mode maps. libstdc++-v3/ChangeLog: * include/bits/hashtable_policy.h (_Insert_base::try_emplace): Do not define for C++11 and C++14. * include/debug/map.h (try_emplace): Use feature test macro. * include/debug/unordered_map (try_emplace): Likewise. * testsuite/17_intro/names.cc: Define try_emplace before C++17. --- Tested x86_64-linux. Pushed to trunk. This needs to be backported too. libstdc++-v3/include/bits/hashtable_policy.h | 2 ++ libstdc++-v3/include/debug/map.h | 2 +- libstdc++-v3/include/debug/unordered_map | 2 +- libstdc++-v3/testsuite/17_intro/names.cc | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index ecf50313d09..b5f837e6061 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1008,6 +1008,7 @@ namespace __detail return __h._M_insert(__hint, __v, __node_gen, __unique_keys{}); } +#ifdef __glibcxx_unordered_map_try_emplace // C++ >= 17 && HOSTED template std::pair try_emplace(const_iterator, _KType&& __k, _Args&&... __args) @@ -1029,6 +1030,7 @@ namespace __detail __node._M_node = nullptr; return { __it, true }; } +#endif void insert(initializer_list __l) diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index d0e398f0fd9..5323a2b0d95 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -344,7 +344,7 @@ namespace __debug } -#if __cplusplus > 201402L +#ifdef __glibcxx_map_try_emplace // C++ >= 17 && HOSTED template pair try_emplace(const key_type& __k, _Args&&... __args) diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index 1acafd8face..cc24fd0d893 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -442,7 +442,7 @@ namespace __debug _M_check_rehashed(__bucket_count); } -#if __cplusplus > 201402L +#ifdef __glibcxx_unordered_map_try_emplace // C++ >= 17 && HOSTED template pair try_emplace(const key_type& __k, _Args&&... __args) diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc index 5deb310dc31..1952028d2cf 100644 --- a/libstdc++-v3/testsuite/17_intro/names.cc +++ b/libstdc++-v3/testsuite/17_intro/names.cc @@ -138,6 +138,8 @@ // defines to_chars_result::ptr and to_chars_result::ec #define ec ( #define ptr ( +// and define try_emplace +#define try_emplace ( #endif // These clash with newlib so don't use them.