[{"id":3672587,"web_url":"http://patchwork.ozlabs.org/comment/3672587/","msgid":"<CAKvuMXBgAdPrtESF-g57a9_Cj+VNNR7dTxkCcmLwTPN5FUBcUw@mail.gmail.com>","list_archive_url":null,"date":"2026-04-02T07:48:38","subject":"Re: [PATCH] libstdc++: Use __cpp_lib_map_try_emplace feature test\n macro","submitter":{"id":90409,"url":"http://patchwork.ozlabs.org/api/people/90409/","name":"Tomasz Kaminski","email":"tkaminsk@redhat.com"},"content":"On Thu, Apr 2, 2026 at 9:39 AM Jonathan Wakely <jwakely@redhat.com> wrote:\n\n> Check the relevant macro for insert_or_assign members, instead of just\n> checking the value of __cplusplus.\n>\n> Also use Doxygen grouping to make docs for try_emplace apply to all\n> three overloads.\n>\n> libstdc++-v3/ChangeLog:\n>\n>         * include/bits/stl_map.h (map::try_emplace): Move #endif and use\n>         Doxygen's @{ to document all three overloads together.\n>         (map::insert_or_assign): Use relevant feature test macro.\n> ---\n>\n> Tested x86_64-linux.\n>\nLGTM.\n\n>\n>  libstdc++-v3/include/bits/stl_map.h | 11 ++++++-----\n>  1 file changed, 6 insertions(+), 5 deletions(-)\n>\n> diff --git a/libstdc++-v3/include/bits/stl_map.h\n> b/libstdc++-v3/include/bits/stl_map.h\n> index 72a7392dbb77..1e119a95b5cd 100644\n> --- a/libstdc++-v3/include/bits/stl_map.h\n> +++ b/libstdc++-v3/include/bits/stl_map.h\n> @@ -870,6 +870,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER\n>         *  to the first is returned.\n>         *\n>         *  Insertion requires logarithmic time (if the hint is not taken).\n> +       *\n> +       *  @{\n>         */\n>        template <typename... _Args>\n>         iterator\n> @@ -906,7 +908,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER\n>             __i = iterator(__true_hint.first);\n>           return __i;\n>         }\n> -#endif\n>\n>  #ifdef __glibcxx_associative_heterogeneous_insertion  // C++26\n>        template <__heterogeneous_tree_key<map> _Kt, typename ..._Args>\n> @@ -927,6 +928,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER\n>           return __i;\n>         }\n>  #endif\n> +      /// @}\n> +#endif // __glibcxx_map_try_emplace\n>\n>        /**\n>         *  @brief Attempts to insert a std::pair into the %map.\n> @@ -1074,7 +1077,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER\n>         insert(_InputIterator __first, _InputIterator __last)\n>         { _M_t._M_insert_range_unique(__first, __last); }\n>\n> -#if __cplusplus > 201402L\n> +#ifdef __glibcxx_map_try_emplace // >= C++17 && HOSTED\n>        /**\n>         *  @brief Attempts to insert or assign a std::pair into the %map.\n>         *  @param __k    Key to use for finding a possibly existing pair in\n> @@ -1150,9 +1153,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER\n>         }\n>  #endif\n>        ///@}\n> -#endif\n>\n> -#if __cplusplus > 201402L\n>        ///@{\n>        /**\n>         *  @brief Attempts to insert or assign a std::pair into the %map.\n> @@ -1238,7 +1239,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER\n>         }\n>  #endif\n>        ///@}\n> -#endif\n> +#endif // __glibcxx_map_try_emplace\n>\n>  #if __cplusplus >= 201103L\n>        // _GLIBCXX_RESOLVE_LIB_DEFECTS\n> --\n> 2.53.0\n>\n>","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=fpr6d5IM;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=fpr6d5IM","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.129.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmYsm1qRWz1yFv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 02 Apr 2026 18:49:48 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 665864BA23E9\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  2 Apr 2026 07:49:46 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id 476A34BA2E33\n for <gcc-patches@gcc.gnu.org>; Thu,  2 Apr 2026 07:48:54 +0000 (GMT)","from mail-yw1-f198.google.com (mail-yw1-f198.google.com\n [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-251-3q9ibTT6NmerSSS_oGWIgQ-1; Thu, 02 Apr 2026 03:48:50 -0400","by mail-yw1-f198.google.com with SMTP id\n 00721157ae682-79064868702so10786877b3.3\n for <gcc-patches@gcc.gnu.org>; Thu, 02 Apr 2026 00:48:50 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 665864BA23E9","OpenDKIM Filter v2.11.0 sourceware.org 476A34BA2E33"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 476A34BA2E33","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 476A34BA2E33","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775116134; cv=none;\n b=B0xc69H192ZmxGKySvQUeP9nyNYGl92fQnHzrlX4ASQk1P0+VoNpYamcMglMzaTS4QXSYfLyWXFjjEui1wrSV9fQg/0ZPr1WNNYydX2kCH6wTjcyfsZWU3ikifH9UrecMwNQM3dePpBhzLxpC0K5Cftjf6gfhzbhGaVu0lD78Ig=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775116134; c=relaxed/simple;\n bh=3uwEY7y0ZKtuZpsxXec2RiMFIz1KHiEFTawkiemywbw=;\n h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;\n b=gbzOfHuky4cjjWBEAcXozFWFIjB7WfPBgZmTfnEL2xsOBLqZvBevSd/ftQaJbWl6E784PqopTa/QEStN1GiGmCDpfBSlw6eSNd9oQTPCvj83cvCZjTx+/4aOb6NwZ+XWOE9RUcOtvYnWAZEDIGoOV/fbGPiXdwaVJAdFfzshbL4=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775116133;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n in-reply-to:in-reply-to:references:references;\n bh=wefa9oP5h+iHkyofKaj+rEHjppbg/uZ8x1hlRqyOMDg=;\n b=fpr6d5IMqpL9lHh97PtyxlW2fHyKJf9UW2bsDS+loInVscBpxJb36wRmegKwvkV0PCy2MS\n xfAD1rM13U69ku+8igy9HVV6bNQILDZO9cT3D6q974Z/8R239swVtlw3gz/y7E9B7ruGti\n 4ERDNL4MA49Fz9/jyqVGeJsxmDqY4Qw=","X-MC-Unique":"3q9ibTT6NmerSSS_oGWIgQ-1","X-Mimecast-MFC-AGG-ID":"3q9ibTT6NmerSSS_oGWIgQ_1775116130","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775116130; x=1775720930;\n h=cc:to:subject:message-id:date:from:in-reply-to:references\n :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=wefa9oP5h+iHkyofKaj+rEHjppbg/uZ8x1hlRqyOMDg=;\n b=iXqDwwiTWcwbko/8N5eqQmg2p1OdNvqcZ8hyNhSTFrS+xEmcmOxzoCunlTGHZhRvTR\n Tueas16dKTohhXtiKVt0iyDWqzo9rnF9fssM8P7nQgl5qrCJhjq1UZwC6E4x+nC3AxB8\n HUHGASpno79RFbtsGBdohs7V2fCm8cuJeOs0j6TfbtcZCXu7QYkqyX4xOocfX2MfHGOa\n Keecr4VDh98EWvmdnu/rB65qrScv5JUcBwyxUh5dZ0dCjIWUoF7ATMhskXyVfL4EUrSR\n 3g44EtkEPjS6Virp8kbEhoop4KrKEAogWmFJiUK9QktpHFbCrHP+b7yqlU8W95/UgO/0\n kumg==","X-Gm-Message-State":"AOJu0YzDT/rUjR5p7YfBqF0fENd41MEPf/ghMNNoBtVN0OAK/39UiE8k\n 3yyp6pFfcvXzZ1/Pfzxq06vqigjdOHHlZiyHJ00xyjRRzdPzaKh7WlfZc7DRGx1kz5iNRGzlcJD\n 1ODbKE0P/t074S5b1ZUmO3IiSTh1u3FjZ/IG0h56+nnjiKDYETNfVr2K22GCaBxm2t2VHISkr5d\n h5/v+FZcyM/epMKib1dFG3yfd3vfpYOZfsmg==","X-Gm-Gg":"AeBDieuHFbe39OTDK7FMnsKdVg+TQa35tTgrJb0io/CTdERBq2om64YZN2fvRvRdoJB\n LmXaTmyQZGotAP59wiaMPPTKRTMKWdpzYVFF+oRvwk5jOtiEz15MRmSUadxO/NZGGAhmkT7ci/q\n Q23THaOFe3zDdMhRkFiZujBJ2ED33fjroptvLOKlAk4J7UxaUhfkjFxx4cnNeBhtlq7X/rophVn\n nnOXt6UnxCxflCX32eIIkyMFyW42+bFsn/NupKXQg+mmuUpjIZNSLQVwi0Wj+hYiY93","X-Received":["by 2002:a05:690c:101:b0:7a1:6e8:d905 with SMTP id\n 00721157ae682-7a211c4bfb4mr71689257b3.29.1775116129629;\n Thu, 02 Apr 2026 00:48:49 -0700 (PDT)","by 2002:a05:690c:101:b0:7a1:6e8:d905 with SMTP id\n 00721157ae682-7a211c4bfb4mr71689127b3.29.1775116129243; Thu, 02 Apr 2026\n 00:48:49 -0700 (PDT)"],"MIME-Version":"1.0","References":"<20260402073844.901461-1-jwakely@redhat.com>","In-Reply-To":"<20260402073844.901461-1-jwakely@redhat.com>","From":"Tomasz Kaminski <tkaminsk@redhat.com>","Date":"Thu, 2 Apr 2026 09:48:38 +0200","X-Gm-Features":"AQROBzA83sUYJE-z1Dx7TLdgL4pXAknXZvXbWlkPePO-kwi0sTRa_6KJ2tqpmM0","Message-ID":"\n <CAKvuMXBgAdPrtESF-g57a9_Cj+VNNR7dTxkCcmLwTPN5FUBcUw@mail.gmail.com>","Subject":"Re: [PATCH] libstdc++: Use __cpp_lib_map_try_emplace feature test\n macro","To":"Jonathan Wakely <jwakely@redhat.com>","Cc":"gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"k3wqZlE42V630YfzsGT8yh38_bMjSecKBou387S4yEc_1775116130","X-Mimecast-Originator":"redhat.com","Content-Type":"multipart/alternative; boundary=\"00000000000051b63b064e756e37\"","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}}]