11 #ifndef ROOT_TADOPTALLOCATOR 12 #define ROOT_TADOPTALLOCATOR 59 using pointer =
typename StdAlloc_t::pointer;
71 enum class EAllocType : char { kOwning, kAdopting, kAdoptingNoAllocYet };
93 template <
class U,
class... Args>
99 fStdAllocator.construct(p, args...);
107 if (n > std::size_t(-1) /
sizeof(
T))
108 throw std::bad_alloc();
114 return StdAllocTraits_t::allocate(fStdAllocator, n);
120 if (p != fInitialAddress)
121 StdAllocTraits_t::deallocate(fStdAllocator, p, n);
128 fStdAllocator.destroy(p);
152 template <
typename U>
157 template <
typename T>
172 template <
typename U>
176 throw std::runtime_error(
"Cannot rebind owning RAdoptAllocator");
179 bool *
allocate(std::size_t
n) {
return fStdAllocator.allocate(n); }
181 template <
typename U,
class... Args>
184 fStdAllocator.construct(p, std::forward<Args>(args)...);
187 void deallocate(
bool *p, std::size_t
s) noexcept { fStdAllocator.deallocate(p,
s); }
192 fStdAllocator.destroy(p);
200 template <
typename T>
pointer allocate(std::size_t n)
Allocate some memory If an address has been adopted, at the first call, that address is returned...
void construct(U *p, Args &&... args)
void construct(U *p, Args &&... args)
Construct an object at a certain memory address.
RAdoptAllocator can provide a view on already allocated memory.
typename StdAlloc_t::const_reference const_reference
Namespace for new ROOT classes and functions.
typename StdAlloc_t::size_type size_type
typename StdAlloc_t::const_pointer const_pointer
std::true_type propagate_on_container_swap
typename StdAlloc_t::pointer pointer
std::allocator_traits< StdAlloc_t > StdAllocTraits_t
void deallocate(pointer p, std::size_t n)
Dellocate some memory if that had not been adopted.
bool operator!=(const RAdoptAllocator &)
bool operator==(const RAdoptAllocator< T > &other)
typename StdAlloc_t::reference reference
typename StdAlloc_t::value_type value_type
typename StdAlloc_t::difference_type difference_type
typename StdAlloc_t::const_reference const_reference
RAdoptAllocator(const RAdoptAllocator< U > &o)
bool operator==(const RAdoptAllocator &)
std::allocator< bool > fStdAllocator
typename StdAlloc_t::reference reference
typename StdAlloc_t::size_type size_type
std::allocator< T > StdAlloc_t
RAdoptAllocator & operator=(const RAdoptAllocator &)=default
bool operator!=(const RAdoptAllocator< T > &other)
void deallocate(bool *p, std::size_t s) noexcept
RAdoptAllocator< U > other
bool * allocate(std::size_t n)
typename StdAlloc_t::pointer pointer
RAdoptAllocator(pointer p)
This is the constructor which allows the allocator to adopt a certain memory region.
static constexpr double s
std::true_type propagate_on_container_move_assignment
typename StdAlloc_t::const_pointer const_pointer
RAdoptAllocator()=default
typename StdAlloc_t::difference_type difference_type
typename StdAlloc_t::value_type value_type
std::allocator< bool > StdAlloc_t