aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-11-01 10:50:02 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2024-11-01 20:36:53 +0000
commit1a5bdeb1128ecfa4ce233218d02ccbb88ce0d8a8 (patch)
tree7cadc0bc81967cd76850647c9eef9ce75a96704e /libstdc++-v3
parentdb798ee38a3f81eff207e889c36c727bb370112c (diff)
downloadgcc-1a5bdeb1128ecfa4ce233218d02ccbb88ce0d8a8.zip
gcc-1a5bdeb1128ecfa4ce233218d02ccbb88ce0d8a8.tar.gz
gcc-1a5bdeb1128ecfa4ce233218d02ccbb88ce0d8a8.tar.bz2
libstdc++: Check feature test macros in unordered containers
Replace some `__cplusplus > 201402L` preprocessor checks with more expressive checks for the appropriate feature test macros. libstdc++-v3/ChangeLog: * include/bits/unordered_map.h: Check __glibcxx_node_extract and __glibcxx_unordered_map_try_emplace instead of __cplusplus. * include/bits/unordered_set.h: Check __glibcxx_node_extract instead of __cplusplus.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/include/bits/unordered_map.h28
-rw-r--r--libstdc++-v3/include/bits/unordered_set.h24
2 files changed, 26 insertions, 26 deletions
diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h
index 8607944..3b47253 100644
--- a/libstdc++-v3/include/bits/unordered_map.h
+++ b/libstdc++-v3/include/bits/unordered_map.h
@@ -137,7 +137,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef typename _Hashtable::difference_type difference_type;
///@}
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
using node_type = typename _Hashtable::node_type;
using insert_return_type = typename _Hashtable::insert_return_type;
#endif
@@ -426,7 +426,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
emplace_hint(const_iterator __pos, _Args&&... __args)
{ return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
/// Extract a node.
node_type
extract(const_iterator __pos)
@@ -449,7 +449,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator
insert(const_iterator, node_type&& __nh)
{ return _M_h._M_reinsert_node(std::move(__nh)).position; }
-#endif // C++17
+#endif // node_extract
#ifdef __glibcxx_unordered_map_try_emplace // C++ >= 17 && HOSTED
/**
@@ -636,7 +636,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ _M_h.insert(__l); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_unordered_map_try_emplace // >= C++17 && HOSTED
/**
* @brief Attempts to insert a std::pair into the %unordered_map.
* @param __k Key to use for finding a possibly existing pair in
@@ -728,7 +728,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__ret.first->second = std::forward<_Obj>(__obj);
return __ret.first;
}
-#endif
+#endif // unordered_map_try_emplace
///@{
/**
@@ -813,7 +813,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
noexcept( noexcept(_M_h.swap(__x._M_h)) )
{ _M_h.swap(__x._M_h); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
template<typename, typename, typename>
friend class std::_Hash_merge_helper;
@@ -842,7 +842,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void
merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
{ merge(__source); }
-#endif // C++17
+#endif // node_extract
// observers.
@@ -1283,7 +1283,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef typename _Hashtable::difference_type difference_type;
///@}
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
using node_type = typename _Hashtable::node_type;
#endif
@@ -1648,7 +1648,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
insert(initializer_list<value_type> __l)
{ _M_h.insert(__l); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
/// Extract a node.
node_type
extract(const_iterator __pos)
@@ -1671,7 +1671,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator
insert(const_iterator __hint, node_type&& __nh)
{ return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); }
-#endif // C++17
+#endif // node_extract
///@{
/**
@@ -1756,7 +1756,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
noexcept( noexcept(_M_h.swap(__x._M_h)) )
{ _M_h.swap(__x._M_h); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
template<typename, typename, typename>
friend class std::_Hash_merge_helper;
@@ -1787,7 +1787,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void
merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
{ merge(__source); }
-#endif // C++17
+#endif // node_extract
// observers.
@@ -2169,7 +2169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_GLIBCXX_END_NAMESPACE_CONTAINER
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
// Allow std::unordered_map access to internals of compatible maps.
template<typename _Key, typename _Val, typename _Hash1, typename _Eq1,
typename _Alloc, typename _Hash2, typename _Eq2>
@@ -2217,7 +2217,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
_S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map)
{ return __map._M_h; }
};
-#endif // C++17
+#endif // node_extract
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
diff --git a/libstdc++-v3/include/bits/unordered_set.h b/libstdc++-v3/include/bits/unordered_set.h
index a2fa2b4..08dcfa2 100644
--- a/libstdc++-v3/include/bits/unordered_set.h
+++ b/libstdc++-v3/include/bits/unordered_set.h
@@ -131,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef typename _Hashtable::difference_type difference_type;
///@}
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
using node_type = typename _Hashtable::node_type;
using insert_return_type = typename _Hashtable::insert_return_type;
#endif
@@ -487,7 +487,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
insert(initializer_list<value_type> __l)
{ _M_h.insert(__l); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
/// Extract a node.
node_type
extract(const_iterator __pos)
@@ -510,7 +510,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator
insert(const_iterator, node_type&& __nh)
{ return _M_h._M_reinsert_node(std::move(__nh)).position; }
-#endif // C++17
+#endif // node_extract
///@{
/**
@@ -594,7 +594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
noexcept( noexcept(_M_h.swap(__x._M_h)) )
{ _M_h.swap(__x._M_h); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
template<typename, typename, typename>
friend class std::_Hash_merge_helper;
@@ -623,7 +623,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void
merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source)
{ merge(__source); }
-#endif // C++17
+#endif // node_extract
// observers.
@@ -999,7 +999,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef typename _Hashtable::difference_type difference_type;
///@}
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
using node_type = typename _Hashtable::node_type;
#endif
@@ -1332,7 +1332,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
insert(initializer_list<value_type> __l)
{ _M_h.insert(__l); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
/// Extract a node.
node_type
extract(const_iterator __pos)
@@ -1355,7 +1355,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator
insert(const_iterator __hint, node_type&& __nh)
{ return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); }
-#endif // C++17
+#endif // node_extract
///@{
/**
@@ -1444,7 +1444,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
noexcept( noexcept(_M_h.swap(__x._M_h)) )
{ _M_h.swap(__x._M_h); }
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
template<typename, typename, typename>
friend class std::_Hash_merge_helper;
@@ -1475,7 +1475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void
merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source)
{ merge(__source); }
-#endif // C++17
+#endif // node_extract
// observers.
@@ -1838,7 +1838,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_GLIBCXX_END_NAMESPACE_CONTAINER
-#if __cplusplus > 201402L
+#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
// Allow std::unordered_set access to internals of compatible sets.
template<typename _Val, typename _Hash1, typename _Eq1, typename _Alloc,
typename _Hash2, typename _Eq2>
@@ -1885,7 +1885,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
_S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set)
{ return __set._M_h; }
};
-#endif // C++17
+#endif // node_extract
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std