aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-06-19 17:21:16 +0100
committerJonathan Wakely <jwakely@redhat.com>2024-06-21 17:07:00 +0100
commit5f10547e021db3a4a34382cd067668f9ef97fdeb (patch)
tree85dc464d99ea213116cb9a56ca5f8ff5839ad1b4
parent139d65d1f5a60ac90479653a4f9b63618509f3f9 (diff)
downloadgcc-5f10547e021db3a4a34382cd067668f9ef97fdeb.zip
gcc-5f10547e021db3a4a34382cd067668f9ef97fdeb.tar.gz
gcc-5f10547e021db3a4a34382cd067668f9ef97fdeb.tar.bz2
libstdc++: Stop using std::__is_pointer in <deque> and <algorithm> [PR115497]
This replaces all uses of the std::__is_pointer type trait with uses of the new __is_pointer built-in. Since the class template was only used to enable some performance optimizations for algorithms, we can use the built-in when __has_builtin(__is_pointer) is true (which is the case for GCC trunk and for current versions of Clang) and just forego the optimization otherwise. Removing the uses of std::__is_pointer means it can be removed from <bits/cpp_type_traits.h>, which is another step towards fixing PR 115497. libstdc++-v3/ChangeLog: PR libstdc++/115497 * include/bits/deque.tcc (__lex_cmp_dit): Replace __is_pointer class template with __is_pointer(T) built-in. (__lexicographical_compare_aux1): Likewise. * include/bits/stl_algobase.h (__equal_aux1): Likewise. (__lexicographical_compare_aux1): Likewise.
-rw-r--r--libstdc++-v3/include/bits/deque.tcc19
-rw-r--r--libstdc++-v3/include/bits/stl_algobase.h13
2 files changed, 21 insertions, 11 deletions
diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc
index 2c12358..deb010a 100644
--- a/libstdc++-v3/include/bits/deque.tcc
+++ b/libstdc++-v3/include/bits/deque.tcc
@@ -1271,18 +1271,21 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __last1,
const _Tp2* __first2, const _Tp2* __last2)
{
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
const bool __simple =
(__is_memcmp_ordered_with<_Tp1, _Tp2>::__value
- && __is_pointer<_Ptr>::__value
+ && __is_pointer(_Ptr)
#if __cplusplus > 201703L && __cpp_lib_concepts
// For C++20 iterator_traits<volatile T*>::value_type is non-volatile
// so __is_byte<T> could be true, but we can't use memcmp with
// volatile data.
- && !is_volatile_v<_Tp1>
- && !is_volatile_v<_Tp2>
+ && !is_volatile_v<_Tp1> && !is_volatile_v<_Tp2>
#endif
);
typedef std::__lexicographical_compare<__simple> _Lc;
+#else
+ typedef std::__lexicographical_compare<false> _Lc;
+#endif
while (__first1._M_node != __last1._M_node)
{
@@ -1327,19 +1330,21 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2)
{
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
const bool __simple =
(__is_memcmp_ordered_with<_Tp1, _Tp2>::__value
- && __is_pointer<_Ptr1>::__value
- && __is_pointer<_Ptr2>::__value
+ && __is_pointer(_Ptr1) && __is_pointer(_Ptr2)
#if __cplusplus > 201703L && __cpp_lib_concepts
// For C++20 iterator_traits<volatile T*>::value_type is non-volatile
// so __is_byte<T> could be true, but we can't use memcmp with
// volatile data.
- && !is_volatile_v<_Tp1>
- && !is_volatile_v<_Tp2>
+ && !is_volatile_v<_Tp1> && !is_volatile_v<_Tp2>
#endif
);
typedef std::__lexicographical_compare<__simple> _Lc;
+#else
+ typedef std::__lexicographical_compare<false> _Lc;
+#endif
while (__first1 != __last1)
{
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 1a0f8c1..57ff2f7 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -1256,8 +1256,10 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{
typedef typename iterator_traits<_II1>::value_type _ValueType1;
const bool __simple = ((__is_integer<_ValueType1>::__value
- || __is_pointer<_ValueType1>::__value)
- && __memcmpable<_II1, _II2>::__value);
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
+ || __is_pointer(_ValueType1)
+#endif
+ ) && __memcmpable<_II1, _II2>::__value);
return std::__equal<__simple>::equal(__first1, __last1, __first2);
}
@@ -1420,10 +1422,10 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{
typedef typename iterator_traits<_II1>::value_type _ValueType1;
typedef typename iterator_traits<_II2>::value_type _ValueType2;
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
const bool __simple =
(__is_memcmp_ordered_with<_ValueType1, _ValueType2>::__value
- && __is_pointer<_II1>::__value
- && __is_pointer<_II2>::__value
+ && __is_pointer(_II1) && __is_pointer(_II2)
#if __cplusplus > 201703L && __glibcxx_concepts
// For C++20 iterator_traits<volatile T*>::value_type is non-volatile
// so __is_byte<T> could be true, but we can't use memcmp with
@@ -1432,6 +1434,9 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
&& !is_volatile_v<remove_reference_t<iter_reference_t<_II2>>>
#endif
);
+#else
+ const bool __simple = false;
+#endif
return std::__lexicographical_compare<__simple>::__lc(__first1, __last1,
__first2, __last2);