9#include "libcopp/utils/config/libcopp_build_features.h"
12LIBCOPP_COPP_NAMESPACE_BEGIN
18 using pointer = typename ::std::allocator_traits<Alloc>::pointer;
19 using value_type = typename ::std::allocator_traits<Alloc>::value_type;
25 template <class Ptr, class = nostd::enable_if_t<::std::is_same<Ptr, value_type*>::value>>
33 if (ptr_ !=
nullptr) {
34 ::std::allocator_traits<Alloc>::deallocate(*alloc_, ptr_, 1);
55 return {a, ::std::allocator_traits<Alloc>::allocate(a, 1)};
59LIBCOPP_COPP_NAMESPACE_END
#define LIBCOPP_UTIL_SYMBOL_VISIBLE
LIBCOPP_UTIL_SYMBOL_VISIBLE allocated_ptr< Alloc > allocate_guarded(Alloc &a)
Allocate space for a single object using a.
Non-standard RAII type for managing pointers obtained from allocators.
allocated_ptr(Alloc &a, pointer p) noexcept
Take ownership of p.
typename ::std::allocator_traits< Alloc >::pointer pointer
typename ::std::allocator_traits< Alloc >::value_type value_type
allocated_ptr & operator=(std::nullptr_t) noexcept
Release ownership of the owned pointer.
~allocated_ptr()
Deallocate the owned pointer.
value_type * get() noexcept
Get the address that the owned pointer refers to.
allocated_ptr(allocated_ptr &&gd) noexcept
Transfer ownership of the owned pointer.
allocated_ptr(Alloc &a, Ptr p)
Convert __ptr to allocator's pointer type and take ownership of it.