[gcc r16-1415] libstdc++: Replace some uses of std::__addressof with std::addressof

Jonathan Wakely redi@gcc.gnu.org
Wed Jun 11 09:36:46 GMT 2025


https://gcc.gnu.org/g:1e8077634fbe80553003c857eb6d77d5b011843e

commit r16-1415-g1e8077634fbe80553003c857eb6d77d5b011843e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu May 22 14:49:25 2025 +0100

    libstdc++: Replace some uses of std::__addressof with std::addressof
    
    Since r16-154-gc91eb5a5c13f14 std::addressof is no less efficient than
    std::__addressof, so change some uses of the latter to the former.  We
    can't change them all, because some uses need to compile as C++98 which
    only has std::__addressof.
    
    Similarly, since r16-848-gb2aeeb2803f97b std::is_constant_evaluated is
    no less efficient than std::__is_constant_evaluated.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/stl_construct.h: Replace std::__addressof with
            std::addressof in code that doesn't need to compile as C++98.
            Replace std::__is_constant_evaluated with
            std::is_constant_evaluated in code that doesn't need to compile
            as C++17 or earlier.
            * include/bits/stl_uninitialized.h: Likewise for __addressof.

Diff:
---
 libstdc++-v3/include/bits/stl_construct.h     | 16 +++++++--------
 libstdc++-v3/include/bits/stl_uninitialized.h | 28 +++++++++++++--------------
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_construct.h b/libstdc++-v3/include/bits/stl_construct.h
index 3ac75715e0e0..217a0416d425 100644
--- a/libstdc++-v3/include/bits/stl_construct.h
+++ b/libstdc++-v3/include/bits/stl_construct.h
@@ -82,7 +82,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       if constexpr (__cplusplus > 201703L && is_array_v<_Tp>)
 	{
 	  for (auto& __x : *__location)
-	    std::destroy_at(std::__addressof(__x));
+	    std::destroy_at(std::addressof(__x));
 	}
       else
 	__location->~_Tp();
@@ -123,7 +123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _Construct(_Tp* __p, _Args&&... __args)
     {
 #if __cpp_constexpr_dynamic_alloc // >= C++20
-      if (std::__is_constant_evaluated())
+      if (std::is_constant_evaluated())
 	{
 	  // Allow std::_Construct to be used in constant expressions.
 	  std::construct_at(__p, std::forward<_Args>(__args)...);
@@ -223,11 +223,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if __cplusplus >= 201103L
       if constexpr (!is_trivially_destructible<_Value_type>::value)
 	for (; __first != __last; ++__first)
-	  std::_Destroy(std::__addressof(*__first));
+	  std::_Destroy(std::addressof(*__first));
 #if __cpp_constexpr_dynamic_alloc // >= C++20
-      else if (std::__is_constant_evaluated())
+      else if (std::is_constant_evaluated())
 	for (; __first != __last; ++__first)
-	  std::destroy_at(std::__addressof(*__first));
+	  std::destroy_at(std::addressof(*__first));
 #endif
 #else
       std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
@@ -249,11 +249,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if __cplusplus >= 201103L
       if constexpr (!is_trivially_destructible<_Value_type>::value)
 	for (; __count > 0; (void)++__first, --__count)
-	  std::_Destroy(std::__addressof(*__first));
+	  std::_Destroy(std::addressof(*__first));
 #if __cpp_constexpr_dynamic_alloc // >= C++20
-      else if (std::__is_constant_evaluated())
+      else if (std::is_constant_evaluated())
 	for (; __count > 0; (void)++__first, --__count)
-	  std::destroy_at(std::__addressof(*__first));
+	  std::destroy_at(std::addressof(*__first));
 #endif
       else
 	std::advance(__first, __count);
diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h
index b1428db48b00..bde787c2beaa 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -839,7 +839,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         {
 	  _UninitDestroyGuard<_ForwardIterator> __guard(__first);
 	  for (; __first != __last; ++__first)
-	    std::_Construct(std::__addressof(*__first));
+	    std::_Construct(std::addressof(*__first));
 	  __guard.release();
 	}
     };
@@ -856,7 +856,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    return;
 
 	  typename iterator_traits<_ForwardIterator>::value_type* __val
-	    = std::__addressof(*__first);
+	    = std::addressof(*__first);
 	  std::_Construct(__val);
 	  if (++__first != __last)
 	    std::fill(__first, __last, *__val);
@@ -873,7 +873,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         {
 	  _UninitDestroyGuard<_ForwardIterator> __guard(__first);
 	  for (; __n > 0; --__n, (void) ++__first)
-	    std::_Construct(std::__addressof(*__first));
+	    std::_Construct(std::addressof(*__first));
 	  __guard.release();
 	  return __first;
 	}
@@ -890,7 +890,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  if (__n > 0)
 	    {
 	      typename iterator_traits<_ForwardIterator>::value_type* __val
-		= std::__addressof(*__first);
+		= std::addressof(*__first);
 	      std::_Construct(__val);
 	      ++__first;
 	      __first = std::fill_n(__first, __n - 1, *__val);
@@ -955,7 +955,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 								__alloc);
       typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
       for (; __first != __last; ++__first)
-	__traits::construct(__alloc, std::__addressof(*__first));
+	__traits::construct(__alloc, std::addressof(*__first));
       __guard.release();
     }
 
@@ -980,7 +980,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 								__alloc);
       typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
       for (; __n > 0; --__n, (void) ++__first)
-	__traits::construct(__alloc, std::__addressof(*__first));
+	__traits::construct(__alloc, std::addressof(*__first));
       __guard.release();
       return __first;
     }
@@ -1007,7 +1007,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	{
 	  _UninitDestroyGuard<_ForwardIterator> __guard(__first);
 	  for (; __first != __last; ++__first)
-	    std::_Construct_novalue(std::__addressof(*__first));
+	    std::_Construct_novalue(std::addressof(*__first));
 	  __guard.release();
 	}
     };
@@ -1033,7 +1033,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	{
 	  _UninitDestroyGuard<_ForwardIterator> __guard(__first);
 	  for (; __n > 0; --__n, (void) ++__first)
-	    std::_Construct_novalue(std::__addressof(*__first));
+	    std::_Construct_novalue(std::addressof(*__first));
 	  __guard.release();
 	  return __first;
 	}
@@ -1089,7 +1089,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       _UninitDestroyGuard<_ForwardIterator> __guard(__result);
       for (; __n > 0; --__n, (void) ++__first, ++__result)
-	std::_Construct(std::__addressof(*__result), *__first);
+	std::_Construct(std::addressof(*__result), *__first);
       __guard.release();
       return __result;
     }
@@ -1112,7 +1112,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       _UninitDestroyGuard<_ForwardIterator> __guard(__result);
       for (; __n > 0; --__n, (void) ++__first, ++__result)
-	std::_Construct(std::__addressof(*__result), *__first);
+	std::_Construct(std::addressof(*__result), *__first);
       __guard.release();
       return {__first, __result};
     }
@@ -1276,11 +1276,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     noexcept(noexcept(std::allocator_traits<_Allocator>::construct(__alloc,
 			 __dest, std::move(*__orig)))
 	     && noexcept(std::allocator_traits<_Allocator>::destroy(
-			    __alloc, std::__addressof(*__orig))))
+			    __alloc, std::addressof(*__orig))))
     {
       typedef std::allocator_traits<_Allocator> __traits;
       __traits::construct(__alloc, __dest, std::move(*__orig));
-      __traits::destroy(__alloc, std::__addressof(*__orig));
+      __traits::destroy(__alloc, std::addressof(*__orig));
     }
 
   // This class may be specialized for specific types.
@@ -1308,8 +1308,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  "relocation is only possible for values of the same type");
       _ForwardIterator __cur = __result;
       for (; __first != __last; ++__first, (void)++__cur)
-	std::__relocate_object_a(std::__addressof(*__cur),
-				 std::__addressof(*__first), __alloc);
+	std::__relocate_object_a(std::addressof(*__cur),
+				 std::addressof(*__first), __alloc);
       return __cur;
     }


More information about the Libstdc++-cvs mailing list