30 #ifndef _ALLOCATED_PTR_H 31 #define _ALLOCATED_PTR_H 1 33 #if __cplusplus < 201103L 34 # include <bits/c++0xwarning.h> 40 namespace std _GLIBCXX_VISIBILITY(default)
42 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 template<
typename _Alloc>
53 : _M_alloc(&__a), _M_ptr(__ptr)
57 template<
typename _Ptr,
58 typename _Req = _Require<is_same<_Ptr, value_type*>>>
60 : _M_alloc(&__a), _M_ptr(
pointer_traits<pointer>::pointer_to(*__ptr))
65 : _M_alloc(__gd._M_alloc), _M_ptr(__gd._M_ptr)
66 { __gd._M_ptr =
nullptr; }
71 if (_M_ptr !=
nullptr)
84 value_type*
get() {
return _S_raw_ptr(_M_ptr); }
87 value_type* _S_raw_ptr(value_type* __ptr) {
return __ptr; }
89 template<
typename _Ptr>
90 auto _S_raw_ptr(_Ptr __ptr) -> decltype(_S_raw_ptr(__ptr.operator->()))
91 {
return _S_raw_ptr(__ptr.operator->()); }
98 template<
typename _Alloc>
105 _GLIBCXX_END_NAMESPACE_VERSION
_Alloc::value_type value_type
The allocated type.
__allocated_ptr< _Alloc > __allocate_guarded(_Alloc &__a)
Allocate space for a single object using __a.
__allocated_ptr(_Alloc &__a, _Ptr __ptr)
Convert __ptr to allocator's pointer type and take ownership of it.
static void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.
static pointer allocate(_Alloc &__a, size_type __n)
Allocate memory.
__allocated_ptr(_Alloc &__a, pointer __ptr) noexcept
Take ownership of __ptr.
Non-standard RAII type for managing pointers obtained from allocators.
__allocated_ptr(__allocated_ptr &&__gd) noexcept
Transfer ownership of the owned pointer.
Uniform interface to all pointer-like types.
~__allocated_ptr()
Deallocate the owned pointer.
__allocated_ptr & operator=(std::nullptr_t) noexcept
Release ownership of the owned pointer.
__pointer pointer
The allocator's pointer type.
ISO C++ entities toplevel namespace is std.