MySQL 8.0.40
Source Code Documentation
|
Lightweight convenience wrapper which manages dynamically allocated over-aligned type. More...
#include <ut0new.h>
Public Member Functions | |
~aligned_pointer () | |
Destructor. More... | |
template<typename... Args> | |
void | alloc (Args &&...args) |
Allocates sufficiently large memory of dynamic storage duration to fit the instance of type T at the address which is aligned to Alignment bytes. More... | |
template<typename... Args> | |
void | alloc_withkey (PSI_memory_key_t key, Args &&...args) |
Allocates sufficiently large memory of dynamic storage duration to fit the instance of type T at the address which is aligned to Alignment bytes. More... | |
void | dealloc () |
Invokes the destructor of instance of type T, if applicable. More... | |
operator T* () const | |
Conversion operator. More... | |
Private Attributes | |
T * | ptr = nullptr |
Lightweight convenience wrapper which manages dynamically allocated over-aligned type.
Wrapper makes use of RAII to do the resource cleanup.
Example usage: struct My_fancy_type { My_fancy_type(int x, int y) : _x(x), _y(y) {} int _x, _y; };
aligned_pointer<My_fancy_type, 32> ptr; ptr.alloc(10, 5); My_fancy_type *p = ptr; assert(p->_x == 10 && p->_y == 5);
T | Type to be managed. |
Alignment | Number of bytes to align the type T to. |
|
inline |
Destructor.
Invokes destructor of the underlying instance of type T. Releases dynamically allocated resources, if there had been left any.
|
inline |
Allocates sufficiently large memory of dynamic storage duration to fit the instance of type T at the address which is aligned to Alignment bytes.
Constructs the instance of type T with given Args.
Underlying instance of type T is accessed through the conversion operator.
[in] | args | Any number and type of arguments that type T can be constructed with. |
|
inline |
Allocates sufficiently large memory of dynamic storage duration to fit the instance of type T at the address which is aligned to Alignment bytes.
Constructs the instance of type T with given Args. Instruments the memory with given PSI memory key in case PFS memory support is enabled.
Underlying instance of type T is accessed through the conversion operator.
[in] | key | PSI memory key to be used for PFS memory instrumentation. |
[in] | args | Any number and type of arguments that type T can be constructed with. |
|
inline |
Invokes the destructor of instance of type T, if applicable.
Releases the resources previously allocated with alloc().
|
inline |
Conversion operator.
Used for accessing the underlying instance of type T.
|
private |