]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Do not define _Insert_base::try_emplace before C++17
authorJonathan Wakely <jwakely@redhat.com>
Fri, 8 Nov 2024 13:58:23 +0000 (13:58 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 8 Nov 2024 14:39:56 +0000 (14:39 +0000)
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.

libstdc++-v3/include/bits/hashtable_policy.h
libstdc++-v3/include/debug/map.h
libstdc++-v3/include/debug/unordered_map
libstdc++-v3/testsuite/17_intro/names.cc

index ecf50313d09c22857a6e15f8a9364f83c487ca29..b5f837e60619be6da8dada3a94fa80edd33572a7 100644 (file)
@@ -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<typename _KType, typename... _Args>
        std::pair<iterator, bool>
        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<value_type> __l)
index d0e398f0fd97ebcc7a904629562cdb07c3626937..5323a2b0d95076c70f7d625775406dccda6b76e6 100644 (file)
@@ -344,7 +344,7 @@ namespace __debug
        }
 
 
-#if __cplusplus > 201402L
+#ifdef __glibcxx_map_try_emplace // C++ >= 17 && HOSTED
       template <typename... _Args>
         pair<iterator, bool>
         try_emplace(const key_type& __k, _Args&&... __args)
index 1acafd8facea6e4f0d674eb9cc2d870c7ba58d9b..cc24fd0d89303da6b25db6f5585538e30f21c6c5 100644 (file)
@@ -442,7 +442,7 @@ namespace __debug
          _M_check_rehashed(__bucket_count);
        }
 
-#if __cplusplus > 201402L
+#ifdef __glibcxx_unordered_map_try_emplace // C++ >= 17 && HOSTED
       template <typename... _Args>
        pair<iterator, bool>
        try_emplace(const key_type& __k, _Args&&... __args)
index 5deb310dc313463b50a6d856964a441622c200e2..1952028d2cf0fc3fb62025a4ec5a6d3cae99afef 100644 (file)
 // <charconv> defines to_chars_result::ptr and to_chars_result::ec
 #define ec (
 #define ptr (
+// <map> and <unordered_map> define try_emplace
+#define try_emplace (
 #endif
 
 // These clash with newlib so don't use them.