cds  2.3.2
cds::opt::v::initialized_dynamic_buffer< T, Alloc, Exp2 > Class Template Reference

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_bufferoperator= (const initialized_dynamic_buffer &)=delete
 
value_typeoperator[] (size_t i)
 Get item i.
 
const value_typeoperator[] (size_t i) const
 Get item i, const version.
 
size_t capacity () const noexcept
 Returns buffer capacity.
 
void zeroize ()
 Zeroize the buffer.
 
value_typebuffer () noexcept
 Returns pointer to buffer array.
 
value_typebuffer () 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
 

Detailed Description

template<typename T, class Alloc = CDS_DEFAULT_ALLOCATOR, bool Exp2 = true>
class cds::opt::v::initialized_dynamic_buffer< T, Alloc, Exp2 >

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.

Template parameters:
  • T - item type storing in the buffer
  • Alloc - 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.

Constructor & Destructor Documentation

◆ initialized_dynamic_buffer()

template<typename T , class Alloc = CDS_DEFAULT_ALLOCATOR, bool Exp2 = true>
cds::opt::v::initialized_dynamic_buffer< T, Alloc, Exp2 >::initialized_dynamic_buffer ( size_t  nCapacity)
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.

Member Function Documentation

◆ mod()

template<typename T , class Alloc = CDS_DEFAULT_ALLOCATOR, bool Exp2 = true>
size_t cds::opt::v::initialized_dynamic_buffer< T, Alloc, Exp2 >::mod ( size_t  idx)
inline

Returns idx % capacity()

If the buffer size is a power of two, binary arithmethics is used instead of modulo arithmetics


The documentation for this class was generated from the following file:

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:52 by Doxygen 1.8.13