32#ifndef MYSQL_RESOURCE_ALLOCATOR_H_
33#define MYSQL_RESOURCE_ALLOCATOR_H_
95 if (
p ==
nullptr)
throw std::bad_alloc();
139 template <
class U,
class... Args>
140 [[deprecated(
"std::allocator::construct is deprecated in C++17")]]
void
142 assert(
p !=
nullptr);
143 ::new ((
void *)
p)
U(std::forward<Args>(args)...);
152 [[deprecated(
"std::allocator::destroy is deprecated in C++17")]]
void destroy(
154 assert(
p !=
nullptr);
163 [[deprecated(
"std::allocator::max_size is deprecated in C++17")]]
size_type
165 return std::numeric_limits<size_type>::max() /
sizeof(T);
Allocator using a Memory_resource to do the allocator.
Definition: allocator.h:54
value_type * pointer
Definition: allocator.h:60
std::size_t size_type
Definition: allocator.h:57
void construct(U *p, Args &&... args)
In-place construct a new object of the given type.
Definition: allocator.h:141
const Memory_resource m_memory_resource
The underlying Memory_resource object.
Definition: allocator.h:179
T & reference
Definition: allocator.h:63
void destroy(pointer p)
Destroy an object but do not deallocate the memory it occupies.
Definition: allocator.h:152
const value_type * const_pointer
Definition: allocator.h:61
Allocator(Memory_resource memory_resource=Memory_resource())
Construct a new Allocator using the given Memory_resource.
Definition: allocator.h:71
std::ptrdiff_t difference_type
Definition: allocator.h:58
size_type max_size() const
The maximum number of T objects that fit in memory.
Definition: allocator.h:164
pointer allocate(size_type n, const_pointer hint=nullptr)
Use the Memory_resource to allocate the given number of elements of type T.
Definition: allocator.h:92
Allocator(const Allocator< U > &other)
Implicit conversion from other instance.
Definition: allocator.h:79
Memory_resource get_memory_resource() const
Return the underlying Memory_resource object.
Definition: allocator.h:175
const T & const_reference
Definition: allocator.h:64
void deallocate(pointer p, size_type size)
Use the Memory_resource to deallocate the given pointer.
Definition: allocator.h:104
T value_type
Definition: allocator.h:56
std::function< void(pointer)> get_deleter()
Return a Deleter function for objects allocated by this class.
Definition: allocator.h:121
Polymorphism-free memory resource class with custom allocator and deallocator functions.
Definition: memory_resource.h:88
void deallocate(Ptr_t p) const
Deallocate memory using the provided deallocator.
Definition: memory_resource.h:118
Deallocator_t get_deallocator() const
Return the deallocator.
Definition: memory_resource.h:121
void * allocate(Size_t n) const
Allocate memory using the provided allocator.
Definition: memory_resource.h:113
const char * p
Definition: ctype-mb.cc:1237
#define U
Definition: ctype-tis620.cc:75
Class that wraps resources in a polymorphic manner.
Definition: allocator.h:40
bool operator!=(const Allocator< T > &a1, const Allocator< T > &a2)
Compare two Allocator objects for inequality.
Definition: allocator.h:191
bool operator==(const Allocator< T > &a1, const Allocator< T > &a2)
Compare two Allocator objects for equality.
Definition: allocator.h:184
Definition: gcs_xcom_synode.h:64
Rebind the allocator as requried by the Allocator named requirement.
Definition: allocator.h:170
Allocator< U > other
Definition: allocator.h:171
int n
Definition: xcom_base.cc:509