]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use __cpp_lib_map_try_emplace feature test macro
authorJonathan Wakely <jwakely@redhat.com>
Wed, 1 Apr 2026 14:16:38 +0000 (15:16 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 2 Apr 2026 12:59:53 +0000 (13:59 +0100)
Check the relevant macro for insert_or_assign members, instead of just
checking the value of __cplusplus.

Also use Doxygen grouping to make docs for try_emplace apply to all
three overloads.

libstdc++-v3/ChangeLog:

* include/bits/stl_map.h (map::try_emplace): Move #endif and use
Doxygen's @{ to document all three overloads.
(map::insert_or_assign): Use relevant feature test macro.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/include/bits/stl_map.h

index 72a7392dbb77c645fd601560632b49d35bda597f..1e119a95b5cda02b036aa7bd1a63129dd36a2383 100644 (file)
@@ -870,6 +870,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  to the first is returned.
        *
        *  Insertion requires logarithmic time (if the hint is not taken).
+       *
+       *  @{
        */
       template <typename... _Args>
        iterator
@@ -906,7 +908,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
            __i = iterator(__true_hint.first);
          return __i;
        }
-#endif
 
 #ifdef __glibcxx_associative_heterogeneous_insertion  // C++26
       template <__heterogeneous_tree_key<map> _Kt, typename ..._Args>
@@ -927,6 +928,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
          return __i;
        }
 #endif
+      /// @}
+#endif // __glibcxx_map_try_emplace
 
       /**
        *  @brief Attempts to insert a std::pair into the %map.
@@ -1074,7 +1077,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        insert(_InputIterator __first, _InputIterator __last)
        { _M_t._M_insert_range_unique(__first, __last); }
 
-#if __cplusplus > 201402L
+#ifdef __glibcxx_map_try_emplace // >= C++17 && HOSTED
       /**
        *  @brief Attempts to insert or assign a std::pair into the %map.
        *  @param __k    Key to use for finding a possibly existing pair in
@@ -1150,9 +1153,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        }
 #endif
       ///@}
-#endif
 
-#if __cplusplus > 201402L
       ///@{
       /**
        *  @brief Attempts to insert or assign a std::pair into the %map.
@@ -1238,7 +1239,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        }
 #endif
       ///@}
-#endif
+#endif // __glibcxx_map_try_emplace
 
 #if __cplusplus >= 201103L
       // _GLIBCXX_RESOLVE_LIB_DEFECTS