]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/bits/allocated_ptr.h
Avoid global bitmap space in ranger.
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / allocated_ptr.h
index 63088c22d80d697ed5f93a36329f014748220d92..26a07a1d34f25753c47ef1de4d3884db0a0902e8 100644 (file)
@@ -1,6 +1,6 @@
 // Guarded Allocation -*- C++ -*-
 
-// Copyright (C) 2014-2015 Free Software Foundation, Inc.
+// Copyright (C) 2014-2024 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -40,6 +40,7 @@
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
+/// @cond undocumented
 
   /// Non-standard RAII type for managing pointers obtained from allocators.
   template<typename _Alloc>
@@ -50,14 +51,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       /// Take ownership of __ptr
       __allocated_ptr(_Alloc& __a, pointer __ptr) noexcept
-      : _M_alloc(&__a), _M_ptr(__ptr)
+      : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr)
       { }
 
       /// Convert __ptr to allocator's pointer type and take ownership of it
       template<typename _Ptr,
               typename _Req = _Require<is_same<_Ptr, value_type*>>>
       __allocated_ptr(_Alloc& __a, _Ptr __ptr)
-      : _M_alloc(&__a), _M_ptr(pointer_traits<pointer>::pointer_to(*__ptr))
+      : _M_alloc(std::__addressof(__a)),
+       _M_ptr(pointer_traits<pointer>::pointer_to(*__ptr))
       { }
 
       /// Transfer ownership of the owned pointer
@@ -81,15 +83,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
       /// Get the address that the owned pointer refers to.
-      value_type* get() { return _S_raw_ptr(_M_ptr); }
+      value_type* get() { return std::__to_address(_M_ptr); }
 
     private:
-      value_type* _S_raw_ptr(value_type* __ptr) { return __ptr; }
-
-      template<typename _Ptr>
-       auto _S_raw_ptr(_Ptr __ptr) -> decltype(_S_raw_ptr(__ptr.operator->()))
-       { return _S_raw_ptr(__ptr.operator->()); }
-
       _Alloc* _M_alloc;
       pointer _M_ptr;
     };
@@ -102,6 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) };
     }
 
+/// @endcond
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std