cds
2.3.2
|
Dynamically allocated initialized 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 | |
initialized_dynamic_buffer (size_t nCapacity) | |
Allocates dynamic buffer of given nCapacity . More... | |
~initialized_dynamic_buffer () | |
Destroys dynamically allocated buffer. | |
initialized_dynamic_buffer (const initialized_dynamic_buffer &)=delete | |
initialized_dynamic_buffer & | operator= (const initialized_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 initialized buffer.
One of available type for opt::buffer
option.
This buffer maintains dynamically allocated array of initialized default-constructed elements. 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