![]() |
MySQL 8.0.43
Source Code Documentation
|
Allocator using a Memory_resource to do the allocator. More...
#include <allocator.h>
Public Types | |
| using | value_type = T |
| using | size_type = std::size_t |
| using | difference_type = std::ptrdiff_t |
Public Member Functions | |
| Allocator (Memory_resource memory_resource=Memory_resource()) | |
| Construct a new Allocator using the given Memory_resource. More... | |
| template<class U > | |
| Allocator (const Allocator< U > &other) | |
| Implicit conversion from other instance. More... | |
| constexpr T * | allocate (size_type n) |
| Use the Memory_resource to allocate the given number of elements of type T. More... | |
| constexpr void | deallocate (T *p, size_type size) |
| Use the Memory_resource to deallocate the given pointer. More... | |
| std::function< void(T *)> | get_deleter () |
| Return a Deleter function for objects allocated by this class. More... | |
| Memory_resource | get_memory_resource () const |
| Return the underlying Memory_resource object. More... | |
Private Attributes | |
| const Memory_resource | m_memory_resource |
| The underlying Memory_resource object. More... | |
Allocator using a Memory_resource to do the allocator.
A library that allocates memory should allow the user to pass a Memory_resource object which defaults to a default-constructed instance, Memory_resource(). Internally it should create the Allocator<T> classes it needs (possibly several, for different classes T), using the given Memory_resource object. Users of the library outside the server should just use the default Memory_resource. Users of the library inside the server should setup a PSI key and pass the result from memory_resource(Key) to the library.
| using mysqlns::resource::Allocator< T >::difference_type = std::ptrdiff_t |
| using mysqlns::resource::Allocator< T >::size_type = std::size_t |
| using mysqlns::resource::Allocator< T >::value_type = T |
|
inlineexplicit |
Construct a new Allocator using the given Memory_resource.
| memory_resource | The memory resource. By default, this uses a default-constructed Memory_resource, so it uses std::malloc and std::free for allocations. |
|
inlineexplicit |
Implicit conversion from other instance.
This is required by Windows implementation of std::vector<Allocator>.
|
inlineconstexpr |
Use the Memory_resource to allocate the given number of elements of type T.
| n | The number of elements. |
| std::bad_alloc | on out of memory conditions. |
|
inlineconstexpr |
Use the Memory_resource to deallocate the given pointer.
| p | The pointer to deallocate. |
| size | Unused. |
|
inline |
Return a Deleter function for objects allocated by this class.
Such a Deleter must be specified when constructing a smart pointer to an object created by this Allocator, for example:
| Deleter | function that takes a T* as argument and uses the Memory_resource to deallocate it. |
|
inline |
Return the underlying Memory_resource object.
|
private |
The underlying Memory_resource object.