// 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
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
+/// @cond undocumented
/// Non-standard RAII type for managing pointers obtained from allocators.
template<typename _Alloc>
/// 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
}
/// 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;
};
return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) };
}
+/// @endcond
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std