cds
2.3.2
|
Dynamically allocated uninitialized buffer. More...
#include <cds/opt/buffer.h>
Data Structures | |
struct | rebind |
Rebind buffer for other template parameters. More... | |
Public Types | |
typedef T | value_type |
Value type. | |
typedef Alloc | allocator |
Allocator type;. | |
Public Member Functions | |
uninitialized_dynamic_buffer (size_t nCapacity) | |
Allocates dynamic buffer of given nCapacity . More... | |
~uninitialized_dynamic_buffer () | |
Destroys dynamically allocated buffer. | |
uninitialized_dynamic_buffer (const uninitialized_dynamic_buffer &)=delete | |
uninitialized_dynamic_buffer & | operator= (const uninitialized_dynamic_buffer &)=delete |
value_type & | operator[] (size_t i) |
Get item i . | |
const value_type & | operator[] (size_t i) const |
Get item i , const version. | |
size_t | capacity () const noexcept |
Returns buffer capacity. | |
void | zeroize () |
Zeroize the buffer. | |
value_type * | buffer () noexcept |
Returns pointer to buffer array. | |
value_type * | buffer () const noexcept |
Returns pointer to buffer array. | |
size_t | mod (size_t idx) |
Returns idx % capacity() More... | |
Static Public Attributes | |
static constexpr const bool | c_bExp2 = Exp2 |
Exp2 flag | |
Dynamically allocated uninitialized buffer.
One of available type for opt::buffer
option.
This buffer maintains dynamically allocated array of uninitialized elements. You should manually construct each element when needed. Allocation is performed at construction time.
T
- item type storing in the bufferAlloc
- an allocator used for allocating internal buffer (std::allocator
interface)Exp2
- a boolean flag. If it is true
the buffer capacity must be power of two. Otherwise it can be any positive number. Usually, it is required that the buffer has size of a power of two.
|
inline |
Allocates dynamic buffer of given nCapacity
.
If Exp2
class template parameter is true
then actual capacity of allocating buffer is nearest upper to nCapacity
power of two.
|
inline |
Returns idx % capacity()
If the buffer size is a power of two, binary arithmethics is used instead of modulo arithmetics