TwiceAsNice  2019-02-18
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
boost::circular_buffer< T, Alloc > Class Template Reference

Circular buffer - a STL compliant container. More...

#include <base.hpp>

Inheritance diagram for boost::circular_buffer< T, Alloc >:
Inheritance graph
Collaboration diagram for boost::circular_buffer< T, Alloc >:
Collaboration graph

Public Types

typedef Alloc::value_type value_type
 The type of elements stored in the circular_buffer. More...
 
typedef Alloc::pointer pointer
 A pointer to an element. More...
 
typedef Alloc::const_pointer const_pointer
 A const pointer to the element. More...
 
typedef Alloc::reference reference
 A reference to an element. More...
 
typedef Alloc::const_reference const_reference
 A const reference to an element. More...
 
typedef Alloc::difference_type difference_type
 The distance type. More...
 
typedef Alloc::size_type size_type
 The size type. More...
 
typedef Alloc allocator_type
 The type of an allocator used in the circular_buffer. More...
 
typedef cb_details::iterator< circular_buffer< T, Alloc >, cb_details::const_traits< Alloc > > const_iterator
 A const (random access) iterator used to iterate through the circular_buffer. More...
 
typedef cb_details::iterator< circular_buffer< T, Alloc >, cb_details::nonconst_traits< Alloc > > iterator
 A (random access) iterator used to iterate through the circular_buffer. More...
 
typedef boost::reverse_iterator< const_iteratorconst_reverse_iterator
 A const iterator used to iterate backwards through a circular_buffer. More...
 
typedef boost::reverse_iterator< iteratorreverse_iterator
 An iterator used to iterate backwards through a circular_buffer. More...
 
typedef std::pair< pointer, size_typearray_range
 An array range. More...
 
typedef std::pair< const_pointer, size_typeconst_array_range
 A range of a const array. More...
 
typedef size_type capacity_type
 The capacity type. More...
 
typedef call_traits< value_type >::param_type param_value_type
 
typedef call_traits< value_type >::param_type return_value_type
 

Public Member Functions

allocator_type get_allocator () const
 Get the allocator. More...
 
allocator_typeget_allocator ()
 Get the allocator reference. More...
 
iterator begin ()
 Get the iterator pointing to the beginning of the circular_buffer. More...
 
iterator end ()
 Get the iterator pointing to the end of the circular_buffer. More...
 
const_iterator begin () const
 Get the const iterator pointing to the beginning of the circular_buffer. More...
 
const_iterator end () const
 Get the const iterator pointing to the end of the circular_buffer. More...
 
reverse_iterator rbegin ()
 Get the iterator pointing to the beginning of the "reversed" circular_buffer. More...
 
reverse_iterator rend ()
 Get the iterator pointing to the end of the "reversed" circular_buffer. More...
 
const_reverse_iterator rbegin () const
 Get the const iterator pointing to the beginning of the "reversed" circular_buffer. More...
 
const_reverse_iterator rend () const
 Get the const iterator pointing to the end of the "reversed" circular_buffer. More...
 
reference operator[] (size_type index)
 Get the element at the index position. More...
 
return_value_type operator[] (size_type index) const
 Get the element at the index position. More...
 
reference at (size_type index)
 Get the element at the index position. More...
 
return_value_type at (size_type index) const
 Get the element at the index position. More...
 
reference front ()
 Get the first element. More...
 
reference back ()
 Get the last element. More...
 
return_value_type front () const
 Get the first element. More...
 
return_value_type back () const
 Get the last element. More...
 
array_range array_one ()
 Get the first continuous array of the internal buffer. More...
 
array_range array_two ()
 Get the second continuous array of the internal buffer. More...
 
const_array_range array_one () const
 Get the first continuous array of the internal buffer. More...
 
const_array_range array_two () const
 Get the second continuous array of the internal buffer. More...
 
pointer linearize ()
 Linearize the internal buffer into a continuous array. More...
 
size_type size () const
 Get the number of elements currently stored in the circular_buffer. More...
 
size_type max_size () const
 Get the largest possible size or capacity of the circular_buffer. (It depends on allocator's max_size()). More...
 
bool empty () const
 Is the circular_buffer empty? More...
 
bool full () const
 Is the circular_buffer full? More...
 
size_type reserve () const
 Get the maximum number of elements which can be inserted into the circular_buffer without overwriting any of already stored elements. More...
 
capacity_type capacity () const
 Get the capacity of the circular_buffer. More...
 
void set_capacity (capacity_type new_capacity)
 Change the capacity of the circular_buffer. More...
 
void resize (size_type new_size, param_value_type item=value_type())
 Change the size of the circular_buffer. More...
 
void rset_capacity (capacity_type new_capacity)
 Change the capacity of the circular_buffer. More...
 
void rresize (size_type new_size, param_value_type item=value_type())
 Change the size of the circular_buffer. More...
 
 circular_buffer (const allocator_type &alloc=allocator_type())
 Create an empty circular_buffer with a maximum capacity. More...
 
 circular_buffer (capacity_type capacity, const allocator_type &alloc=allocator_type())
 Create an empty circular_buffer with the specified capacity. More...
 
 circular_buffer (size_type n, param_value_type item, const allocator_type &alloc=allocator_type())
 Create a full circular_buffer with the specified capacity and filled with n copies of item. More...
 
 circular_buffer (capacity_type capacity, size_type n, param_value_type item, const allocator_type &alloc=allocator_type())
 Create a circular_buffer with the specified capacity and filled with n copies of item. More...
 
 circular_buffer (const circular_buffer< T, Alloc > &cb)
 The copy constructor. More...
 
template<class InputIterator >
 circular_buffer (InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
 Create a full circular_buffer filled with a copy of the range. More...
 
template<class InputIterator >
 circular_buffer (capacity_type capacity, InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
 Create a circular_buffer with the specified capacity and filled with a copy of the range. More...
 
 ~circular_buffer ()
 The destructor. More...
 
circular_buffer< T, Alloc > & operator= (const circular_buffer< T, Alloc > &cb)
 The assign operator. More...
 
void assign (size_type n, param_value_type item)
 Assign n items into the circular_buffer. More...
 
void assign (capacity_type capacity, size_type n, param_value_type item)
 Assign n items into the circular_buffer specifying the capacity. More...
 
template<class InputIterator >
void assign (InputIterator first, InputIterator last)
 Assign a copy of the range into the circular_buffer. More...
 
template<class InputIterator >
void assign (capacity_type capacity, InputIterator first, InputIterator last)
 Assign a copy of the range into the circular_buffer specifying the capacity. More...
 
void swap (circular_buffer< T, Alloc > &cb)
 Swap the contents of two circular_buffers. More...
 
void push_back (param_value_type item=value_type())
 Insert a new element at the end of the circular_buffer. More...
 
void push_front (param_value_type item=value_type())
 Insert a new element at the beginning of the circular_buffer. More...
 
void pop_back ()
 Remove the last element from the circular_buffer. More...
 
void pop_front ()
 Remove the first element from the circular_buffer. More...
 
iterator insert (iterator pos, param_value_type item=value_type())
 Insert an element at the specified position. More...
 
void insert (iterator pos, size_type n, param_value_type item)
 Insert n copies of the item at the specified position. More...
 
template<class InputIterator >
void insert (iterator pos, InputIterator first, InputIterator last)
 Insert the range [first, last) at the specified position. More...
 
iterator rinsert (iterator pos, param_value_type item=value_type())
 Insert an element before the specified position. More...
 
void rinsert (iterator pos, size_type n, param_value_type item)
 Insert n copies of the item before the specified position. More...
 
template<class InputIterator >
void rinsert (iterator pos, InputIterator first, InputIterator last)
 Insert the range [first, last) before the specified position. More...
 
iterator erase (iterator pos)
 Remove an element at the specified position. More...
 
iterator erase (iterator first, iterator last)
 Erase the range [first, last). More...
 
iterator rerase (iterator pos)
 Remove an element at the specified position. More...
 
iterator rerase (iterator first, iterator last)
 Erase the range [first, last). More...
 
void clear ()
 Remove all stored elements from the circular_buffer. More...
 

Private Member Functions

 BOOST_CLASS_REQUIRE (T, boost, SGIAssignableConcept)
 
void check_position (size_type index) const
 Check if the index is valid. More...
 
template<class Pointer >
void increment (Pointer &p) const
 Increment the pointer. More...
 
template<class Pointer >
void decrement (Pointer &p) const
 Decrement the pointer. More...
 
template<class Pointer >
Pointer add (Pointer p, difference_type n) const
 Add n to the pointer. More...
 
template<class Pointer >
Pointer sub (Pointer p, difference_type n) const
 Subtract n from the pointer. More...
 
pointer map_pointer (pointer p) const
 Map the null pointer to virtual end of circular buffer. More...
 
pointer allocate (size_type n)
 Allocate memory. More...
 
void deallocate (pointer p, size_type n)
 Deallocate memory. More...
 
bool is_uninitialized (const_pointer p) const
 Does the pointer point to the uninitialized memory? More...
 
void replace (pointer pos, param_value_type item)
 Replace an element. More...
 
void construct_or_replace (bool construct, pointer pos, param_value_type item)
 Construct or replace an element. More...
 
void destroy_item (pointer p)
 Destroy an item. More...
 
void destroy_if_constructed (pointer pos)
 Destroy an item only if it has been constructed. More...
 
void destroy_content ()
 Destroy the whole content of the circular buffer. More...
 
void destroy ()
 Destroy content and free allocated memory. More...
 
void initialize (capacity_type capacity)
 Initialize the circular buffer. More...
 
void initialize (capacity_type capacity, param_value_type item)
 Initialize the circular buffer. More...
 
template<class IntegralType >
void initialize (IntegralType n, IntegralType item, const true_type &)
 Specialized initialize method. More...
 
template<class Iterator >
void initialize (Iterator first, Iterator last, const false_type &)
 Specialized initialize method. More...
 
template<class InputIterator >
void initialize (InputIterator first, InputIterator last, const std::input_iterator_tag &)
 Specialized initialize method. More...
 
template<class ForwardIterator >
void initialize (ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &)
 Specialized initialize method. More...
 
template<class IntegralType >
void initialize (capacity_type capacity, IntegralType n, IntegralType item, const true_type &)
 Specialized initialize method. More...
 
template<class Iterator >
void initialize (capacity_type capacity, Iterator first, Iterator last, const false_type &)
 Specialized initialize method. More...
 
template<class InputIterator >
void initialize (capacity_type capacity, InputIterator first, InputIterator last, const std::input_iterator_tag &)
 Specialized initialize method. More...
 
template<class ForwardIterator >
void initialize (capacity_type capacity, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &)
 Specialized initialize method. More...
 
template<class ForwardIterator >
void initialize (capacity_type capacity, ForwardIterator first, ForwardIterator last, size_type distance)
 Helper initialize method. More...
 
void reset (pointer buff, pointer last, capacity_type new_capacity)
 Reset the circular buffer. More...
 
void swap_allocator (circular_buffer< T, Alloc > &cb, const true_type &)
 Specialized method for swapping the allocator. More...
 
void swap_allocator (circular_buffer< T, Alloc > &cb, const false_type &)
 Specialized method for swapping the allocator. More...
 
template<class IntegralType >
void assign (IntegralType n, IntegralType item, const true_type &)
 Specialized assign method. More...
 
template<class Iterator >
void assign (Iterator first, Iterator last, const false_type &)
 Specialized assign method. More...
 
template<class InputIterator >
void assign (InputIterator first, InputIterator last, const std::input_iterator_tag &)
 Specialized assign method. More...
 
template<class ForwardIterator >
void assign (ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &)
 Specialized assign method. More...
 
template<class IntegralType >
void assign (capacity_type new_capacity, IntegralType n, IntegralType item, const true_type &)
 Specialized assign method. More...
 
template<class Iterator >
void assign (capacity_type new_capacity, Iterator first, Iterator last, const false_type &)
 Specialized assign method. More...
 
template<class InputIterator >
void assign (capacity_type new_capacity, InputIterator first, InputIterator last, const std::input_iterator_tag &)
 Specialized assign method. More...
 
template<class ForwardIterator >
void assign (capacity_type new_capacity, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &)
 Specialized assign method. More...
 
template<class Functor >
void assign_n (capacity_type new_capacity, size_type n, const Functor &fnc)
 Helper assign method. More...
 
iterator insert_item (const iterator &pos, param_value_type item)
 Helper insert method. More...
 
template<class IntegralType >
void insert (const iterator &pos, IntegralType n, IntegralType item, const true_type &)
 Specialized insert method. More...
 
template<class Iterator >
void insert (const iterator &pos, Iterator first, Iterator last, const false_type &)
 Specialized insert method. More...
 
template<class InputIterator >
void insert (iterator pos, InputIterator first, InputIterator last, const std::input_iterator_tag &)
 Specialized insert method. More...
 
template<class ForwardIterator >
void insert (const iterator &pos, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &)
 Specialized insert method. More...
 
template<class Wrapper >
void insert_n (const iterator &pos, size_type n, const Wrapper &wrapper)
 Helper insert method. More...
 
template<class IntegralType >
void rinsert (const iterator &pos, IntegralType n, IntegralType item, const true_type &)
 Specialized rinsert method. More...
 
template<class Iterator >
void rinsert (const iterator &pos, Iterator first, Iterator last, const false_type &)
 Specialized rinsert method. More...
 
template<class InputIterator >
void rinsert (iterator pos, InputIterator first, InputIterator last, const std::input_iterator_tag &)
 Specialized insert method. More...
 
template<class ForwardIterator >
void rinsert (const iterator &pos, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &)
 Specialized rinsert method. More...
 
template<class Wrapper >
void rinsert_n (const iterator &pos, size_type n, const Wrapper &wrapper)
 Helper rinsert method. More...
 

Private Attributes

pointer m_buff
 The internal buffer used for storing elements in the circular buffer. More...
 
pointer m_end
 The internal buffer's end (end of the storage space). More...
 
pointer m_first
 The virtual beginning of the circular buffer. More...
 
pointer m_last
 The virtual end of the circular buffer (one behind the last element). More...
 
size_type m_size
 The number of items currently stored in the circular buffer. More...
 
allocator_type m_alloc
 The allocator. More...
 

Friends

template<class Buff , class Traits >
struct cb_details::iterator
 

Detailed Description

template<class T, class Alloc>
class boost::circular_buffer< T, Alloc >

Circular buffer - a STL compliant container.

Parameters
TThe type of the elements stored in the circular_buffer.
Type Requirements T
The T has to be SGIAssignable (SGI STL defined combination of Assignable and CopyConstructible). Moreover T has to be DefaultConstructible if supplied as a default parameter when invoking some of the circular_buffer's methods e.g. insert(iterator pos, const value_type& item = value_type()). And EqualityComparable and/or LessThanComparable if the circular_buffer will be compared with another container.
Parameters
AllocThe allocator type used for all internal memory management.
Type Requirements Alloc
The Alloc has to meet the allocator requirements imposed by STL.
Default Alloc
std::allocator<T>

For detailed documentation of the circular_buffer visit: http://www.boost.org/libs/circular_buffer/doc/circular_buffer.html

Member Typedef Documentation

◆ allocator_type

template<class T, class Alloc>
typedef Alloc boost::circular_buffer< T, Alloc >::allocator_type

The type of an allocator used in the circular_buffer.

◆ array_range

template<class T, class Alloc>
typedef std::pair<pointer, size_type> boost::circular_buffer< T, Alloc >::array_range

An array range.

(A typedef for the std::pair where its first element is a pointer to a beginning of an array and its second element represents a size of the array.)

◆ capacity_type

template<class T, class Alloc>
typedef size_type boost::circular_buffer< T, Alloc >::capacity_type

The capacity type.

(Same as size_type - defined for consistency with the circular_buffer_space_optimized.)

◆ const_array_range

template<class T, class Alloc>
typedef std::pair<const_pointer, size_type> boost::circular_buffer< T, Alloc >::const_array_range

A range of a const array.

(A typedef for the std::pair where its first element is a pointer to a beginning of a const array and its second element represents a size of the const array.)

◆ const_iterator

template<class T, class Alloc>
typedef cb_details::iterator< circular_buffer<T, Alloc>, cb_details::const_traits<Alloc> > boost::circular_buffer< T, Alloc >::const_iterator

A const (random access) iterator used to iterate through the circular_buffer.

◆ const_pointer

template<class T, class Alloc>
typedef Alloc::const_pointer boost::circular_buffer< T, Alloc >::const_pointer

A const pointer to the element.

◆ const_reference

template<class T, class Alloc>
typedef Alloc::const_reference boost::circular_buffer< T, Alloc >::const_reference

A const reference to an element.

◆ const_reverse_iterator

template<class T, class Alloc>
typedef boost::reverse_iterator<const_iterator> boost::circular_buffer< T, Alloc >::const_reverse_iterator

A const iterator used to iterate backwards through a circular_buffer.

◆ difference_type

template<class T, class Alloc>
typedef Alloc::difference_type boost::circular_buffer< T, Alloc >::difference_type

The distance type.

(A signed integral type used to represent the distance between two iterators.)

◆ iterator

template<class T, class Alloc>
typedef cb_details::iterator< circular_buffer<T, Alloc>, cb_details::nonconst_traits<Alloc> > boost::circular_buffer< T, Alloc >::iterator

A (random access) iterator used to iterate through the circular_buffer.

◆ param_value_type

template<class T, class Alloc>
typedef call_traits<value_type>::param_type boost::circular_buffer< T, Alloc >::param_value_type

◆ pointer

template<class T, class Alloc>
typedef Alloc::pointer boost::circular_buffer< T, Alloc >::pointer

A pointer to an element.

◆ reference

template<class T, class Alloc>
typedef Alloc::reference boost::circular_buffer< T, Alloc >::reference

A reference to an element.

◆ return_value_type

template<class T, class Alloc>
typedef call_traits<value_type>::param_type boost::circular_buffer< T, Alloc >::return_value_type

◆ reverse_iterator

template<class T, class Alloc>
typedef boost::reverse_iterator<iterator> boost::circular_buffer< T, Alloc >::reverse_iterator

An iterator used to iterate backwards through a circular_buffer.

◆ size_type

template<class T, class Alloc>
typedef Alloc::size_type boost::circular_buffer< T, Alloc >::size_type

The size type.

(An unsigned integral type that can represent any non-negative value of the container's distance type.)

◆ value_type

template<class T, class Alloc>
typedef Alloc::value_type boost::circular_buffer< T, Alloc >::value_type

The type of elements stored in the circular_buffer.

Constructor & Destructor Documentation

◆ circular_buffer() [1/7]

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::circular_buffer ( const allocator_type alloc = allocator_type())
inlineexplicit

Create an empty circular_buffer with a maximum capacity.

Postcondition
capacity() == max_size() && size() == 0
Parameters
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
Complexity
Constant.
Warning
This constructor has been defined only due to compatibility with the STL container definition. Avoid using it because it may allocate very large amount of memory (depending on allocator's max_size()).

◆ circular_buffer() [2/7]

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::circular_buffer ( capacity_type  capacity,
const allocator_type alloc = allocator_type() 
)
inlineexplicit

Create an empty circular_buffer with the specified capacity.

Postcondition
capacity() == capacity && size() == 0
Parameters
capacityThe maximum number of elements which can be stored in the circular_buffer.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
Complexity
Constant.

◆ circular_buffer() [3/7]

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::circular_buffer ( size_type  n,
param_value_type  item,
const allocator_type alloc = allocator_type() 
)
inline

Create a full circular_buffer with the specified capacity and filled with n copies of item.

Postcondition
capacity() == n && full() && (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] == item
Parameters
nThe number of elements the created circular_buffer will be filled with.
itemThe element the created circular_buffer will be filled with.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in the n).

◆ circular_buffer() [4/7]

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::circular_buffer ( capacity_type  capacity,
size_type  n,
param_value_type  item,
const allocator_type alloc = allocator_type() 
)
inline

Create a circular_buffer with the specified capacity and filled with n copies of item.

Precondition
capacity >= n
Postcondition
capacity() == capacity && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] == item
Parameters
capacityThe capacity of the created circular_buffer.
nThe number of elements the created circular_buffer will be filled with.
itemThe element the created circular_buffer will be filled with.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in the n).

◆ circular_buffer() [5/7]

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::circular_buffer ( const circular_buffer< T, Alloc > &  cb)
inline

The copy constructor.

Creates a copy of the specified circular_buffer.

Postcondition
*this == cb
Parameters
cbThe circular_buffer to be copied.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in the size of cb).

◆ circular_buffer() [6/7]

template<class T, class Alloc>
template<class InputIterator >
boost::circular_buffer< T, Alloc >::circular_buffer ( InputIterator  first,
InputIterator  last,
const allocator_type alloc = allocator_type() 
)
inline

Create a full circular_buffer filled with a copy of the range.

Precondition
Valid range [first, last).
first and last have to meet the requirements of InputIterator.
Postcondition
capacity() == std::distance(first, last) && full() && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... && (*this)[std::distance(first, last) - 1] == *(last - 1)
Parameters
firstThe beginning of the range to be copied.
lastThe end of the range to be copied.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in the std::distance(first, last)).

◆ circular_buffer() [7/7]

template<class T, class Alloc>
template<class InputIterator >
boost::circular_buffer< T, Alloc >::circular_buffer ( capacity_type  capacity,
InputIterator  first,
InputIterator  last,
const allocator_type alloc = allocator_type() 
)
inline

Create a circular_buffer with the specified capacity and filled with a copy of the range.

Precondition
Valid range [first, last).
first and last have to meet the requirements of InputIterator.
Postcondition
capacity() == capacity && size() <= std::distance(first, last) && (*this)[0]== *(last - capacity) && (*this)[1] == *(last - capacity + 1) && ... && (*this)[capacity - 1] == *(last - 1)

If the number of items to be copied from the range [first, last) is greater than the specified capacity then only elements from the range [last - capacity, last) will be copied.
Parameters
capacityThe capacity of the created circular_buffer.
firstThe beginning of the range to be copied.
lastThe end of the range to be copied.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in std::distance(first, last); in min[capacity, std::distance(first, last)] if the InputIterator is a RandomAccessIterator).

◆ ~circular_buffer()

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::~circular_buffer ( )
inline

The destructor.

Destroys the circular_buffer.

Exceptions
Nothing.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (including iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer).
See also
clear()

Member Function Documentation

◆ add()

template<class T, class Alloc>
template<class Pointer >
Pointer boost::circular_buffer< T, Alloc >::add ( Pointer  p,
difference_type  n 
) const
inlineprivate

Add n to the pointer.

◆ allocate()

template<class T, class Alloc>
pointer boost::circular_buffer< T, Alloc >::allocate ( size_type  n)
inlineprivate

Allocate memory.

◆ array_one() [1/2]

template<class T, class Alloc>
array_range boost::circular_buffer< T, Alloc >::array_one ( )
inline

Get the first continuous array of the internal buffer.

This method in combination with array_two() can be useful when passing the stored data into a legacy C API as an array. Suppose there is a circular_buffer of capacity 10, containing 7 characters 'a', 'b', ..., 'g' where buff[0] == 'a', buff[1] == 'b', ... and buff[6] == 'g':

circular_buffer<char> buff(10);

The internal representation is often not linear and the state of the internal buffer may look like this:

|e|f|g| | | |a|b|c|d|
end —^
begin ----—^


where |a|b|c|d| represents the "array one", |e|f|g| represents the "array two" and | | | | is a free space.
Now consider a typical C style function for writing data into a file:

int write(int file_desc, char* buff, int num_bytes);

There are two ways how to write the content of the circular_buffer into a file. Either relying on array_one() and array_two() methods and calling the write function twice:

array_range ar = buff.array_one();
write(file_desc, ar.first, ar.second);
ar = buff.array_two();
write(file_desc, ar.first, ar.second);


Or relying on the linearize() method:

write(file_desc, buff.linearize(), buff.size());

Since the complexity of array_one() and array_two() methods is constant the first option is suitable when calling the write method is "cheap". On the other hand the second option is more suitable when calling the write method is more "expensive" than calling the linearize() method whose complexity is linear.

Returns
The array range of the first continuous array of the internal buffer. In the case the circular_buffer is empty the size of the returned array is 0.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
Warning
In general invoking any method which modifies the internal state of the circular_buffer may delinearize the internal buffer and invalidate the array ranges returned by array_one() and array_two() (and their const versions).
Note
In the case the internal buffer is linear e.g. |a|b|c|d|e|f|g| | | | the "array one" is represented by |a|b|c|d|e|f|g| and the "array two" does not exist (the array_two() method returns an array with the size 0).
See also
array_two(), linearize()

◆ array_one() [2/2]

template<class T, class Alloc>
const_array_range boost::circular_buffer< T, Alloc >::array_one ( ) const
inline

Get the first continuous array of the internal buffer.

This method in combination with array_two() const can be useful when passing the stored data into a legacy C API as an array.

Returns
The array range of the first continuous array of the internal buffer. In the case the circular_buffer is empty the size of the returned array is 0.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
array_two() const; array_one() for more details how to pass data into a legacy C hidapi API.

◆ array_two() [1/2]

template<class T, class Alloc>
array_range boost::circular_buffer< T, Alloc >::array_two ( )
inline

Get the second continuous array of the internal buffer.

This method in combination with array_one() can be useful when passing the stored data into a legacy C API as an array.

Returns
The array range of the second continuous array of the internal buffer. In the case the internal buffer is linear or the circular_buffer is empty the size of the returned array is 0.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
array_one()

◆ array_two() [2/2]

template<class T, class Alloc>
const_array_range boost::circular_buffer< T, Alloc >::array_two ( ) const
inline

Get the second continuous array of the internal buffer.

This method in combination with array_one() const can be useful when passing the stored data into a legacy C API as an array.

Returns
The array range of the second continuous array of the internal buffer. In the case the internal buffer is linear or the circular_buffer is empty the size of the returned array is 0.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
array_one() const

◆ assign() [1/12]

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::assign ( size_type  n,
param_value_type  item 
)
inline

Assign n items into the circular_buffer.

The content of the circular_buffer will be removed and replaced with n copies of the item.

Postcondition
capacity() == n && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] == item
Parameters
nThe number of elements the circular_buffer will be filled with.
itemThe element the circular_buffer will be filled with.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()).
Complexity
Linear (in the n).
See also
operator=, assign(capacity_type, size_type, const_reference), assign(InputIterator, InputIterator), assign(capacity_type, InputIterator, InputIterator)

◆ assign() [2/12]

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::assign ( capacity_type  capacity,
size_type  n,
param_value_type  item 
)
inline

Assign n items into the circular_buffer specifying the capacity.

The capacity of the circular_buffer will be set to the specified value and the content of the circular_buffer will be removed and replaced with n copies of the item.

Precondition
capacity >= n
Postcondition
capacity() == capacity && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] == item
Parameters
capacityThe new capacity.
nThe number of elements the circular_buffer will be filled with.
itemThe element the circular_buffer will be filled with.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()).
Complexity
Linear (in the n).
See also
operator=, assign(size_type, const_reference), assign(InputIterator, InputIterator), assign(capacity_type, InputIterator, InputIterator)

◆ assign() [3/12]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::assign ( InputIterator  first,
InputIterator  last 
)
inline

Assign a copy of the range into the circular_buffer.

The content of the circular_buffer will be removed and replaced with copies of elements from the specified range.

Precondition
Valid range [first, last).
first and last have to meet the requirements of InputIterator.
Postcondition
capacity() == std::distance(first, last) && size() == std::distance(first, last) && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... && (*this)[std::distance(first, last) - 1] == *(last - 1)
Parameters
firstThe beginning of the range to be copied.
lastThe end of the range to be copied.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()).
Complexity
Linear (in the std::distance(first, last)).
See also
operator=, assign(size_type, const_reference), assign(capacity_type, size_type, const_reference), assign(capacity_type, InputIterator, InputIterator)

◆ assign() [4/12]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::assign ( capacity_type  capacity,
InputIterator  first,
InputIterator  last 
)
inline

Assign a copy of the range into the circular_buffer specifying the capacity.

The capacity of the circular_buffer will be set to the specified value and the content of the circular_buffer will be removed and replaced with copies of elements from the specified range.

Precondition
Valid range [first, last).
first and last have to meet the requirements of InputIterator.
Postcondition
capacity() == capacity && size() <= std::distance(first, last) && (*this)[0]== *(last - capacity) && (*this)[1] == *(last - capacity + 1) && ... && (*this)[capacity - 1] == *(last - 1)

If the number of items to be copied from the range [first, last) is greater than the specified capacity then only elements from the range [last - capacity, last) will be copied.
Parameters
capacityThe new capacity.
firstThe beginning of the range to be copied.
lastThe end of the range to be copied.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()).
Complexity
Linear (in std::distance(first, last); in min[capacity, std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
See also
operator=, assign(size_type, const_reference), assign(capacity_type, size_type, const_reference), assign(InputIterator, InputIterator)

◆ assign() [5/12]

template<class T, class Alloc>
template<class IntegralType >
void boost::circular_buffer< T, Alloc >::assign ( IntegralType  n,
IntegralType  item,
const true_type &   
)
inlineprivate

Specialized assign method.

◆ assign() [6/12]

template<class T, class Alloc>
template<class Iterator >
void boost::circular_buffer< T, Alloc >::assign ( Iterator  first,
Iterator  last,
const false_type &   
)
inlineprivate

Specialized assign method.

◆ assign() [7/12]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::assign ( InputIterator  first,
InputIterator  last,
const std::input_iterator_tag &   
)
inlineprivate

Specialized assign method.

◆ assign() [8/12]

template<class T, class Alloc>
template<class ForwardIterator >
void boost::circular_buffer< T, Alloc >::assign ( ForwardIterator  first,
ForwardIterator  last,
const std::forward_iterator_tag &   
)
inlineprivate

Specialized assign method.

◆ assign() [9/12]

template<class T, class Alloc>
template<class IntegralType >
void boost::circular_buffer< T, Alloc >::assign ( capacity_type  new_capacity,
IntegralType  n,
IntegralType  item,
const true_type &   
)
inlineprivate

Specialized assign method.

◆ assign() [10/12]

template<class T, class Alloc>
template<class Iterator >
void boost::circular_buffer< T, Alloc >::assign ( capacity_type  new_capacity,
Iterator  first,
Iterator  last,
const false_type &   
)
inlineprivate

Specialized assign method.

◆ assign() [11/12]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::assign ( capacity_type  new_capacity,
InputIterator  first,
InputIterator  last,
const std::input_iterator_tag &   
)
inlineprivate

Specialized assign method.

◆ assign() [12/12]

template<class T, class Alloc>
template<class ForwardIterator >
void boost::circular_buffer< T, Alloc >::assign ( capacity_type  new_capacity,
ForwardIterator  first,
ForwardIterator  last,
const std::forward_iterator_tag &   
)
inlineprivate

Specialized assign method.

◆ assign_n()

template<class T, class Alloc>
template<class Functor >
void boost::circular_buffer< T, Alloc >::assign_n ( capacity_type  new_capacity,
size_type  n,
const Functor &  fnc 
)
inlineprivate

Helper assign method.

◆ at() [1/2]

template<class T, class Alloc>
reference boost::circular_buffer< T, Alloc >::at ( size_type  index)
inline

Get the element at the index position.

Parameters
indexThe position of the element.
Returns
A reference to the element at the index position.
Exceptions
<code>std::out_of_range</code>when the index is invalid (when index >= size()).
Exception Safety
Strong.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
operator[]

◆ at() [2/2]

template<class T, class Alloc>
return_value_type boost::circular_buffer< T, Alloc >::at ( size_type  index) const
inline

Get the element at the index position.

Parameters
indexThe position of the element.
Returns
A const reference to the element at the index position.
Exceptions
<code>std::out_of_range</code>when the index is invalid (when index >= size()).
Exception Safety
Strong.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
operator[] const

◆ back() [1/2]

template<class T, class Alloc>
reference boost::circular_buffer< T, Alloc >::back ( )
inline

Get the last element.

Precondition
!empty()
Returns
A reference to the last element of the circular_buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
front()

◆ back() [2/2]

template<class T, class Alloc>
return_value_type boost::circular_buffer< T, Alloc >::back ( ) const
inline

Get the last element.

Precondition
!empty()
Returns
A const reference to the last element of the circular_buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
front() const

◆ begin() [1/2]

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::begin ( void  )
inline

Get the iterator pointing to the beginning of the circular_buffer.

Returns
A random access iterator pointing to the first element of the circular_buffer. If the circular_buffer is empty it returns an iterator equal to the one returned by end().
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
end(), rbegin(), rend()

◆ begin() [2/2]

template<class T, class Alloc>
const_iterator boost::circular_buffer< T, Alloc >::begin ( void  ) const
inline

Get the const iterator pointing to the beginning of the circular_buffer.

Returns
A const random access iterator pointing to the first element of the circular_buffer. If the circular_buffer is empty it returns an iterator equal to the one returned by end() const.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
end() const, rbegin() const, rend() const

◆ BOOST_CLASS_REQUIRE()

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::BOOST_CLASS_REQUIRE ( ,
boost  ,
SGIAssignableConcept   
)
private

◆ capacity()

template<class T, class Alloc>
capacity_type boost::circular_buffer< T, Alloc >::capacity ( ) const
inline

Get the capacity of the circular_buffer.

Returns
The maximum number of elements which can be stored in the circular_buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
reserve(), size(), max_size(), set_capacity(capacity_type)

◆ check_position()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::check_position ( size_type  index) const
inlineprivate

Check if the index is valid.

◆ clear()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::clear ( void  )
inline

Remove all stored elements from the circular_buffer.

Postcondition
size() == 0
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer).
See also
~circular_buffer(), erase(iterator), erase(iterator, iterator), rerase(iterator), rerase(iterator, iterator)

◆ construct_or_replace()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::construct_or_replace ( bool  construct,
pointer  pos,
param_value_type  item 
)
inlineprivate

Construct or replace an element.

construct has to be set to true if and only if pos points to an uninitialized memory.

◆ deallocate()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::deallocate ( pointer  p,
size_type  n 
)
inlineprivate

Deallocate memory.

◆ decrement()

template<class T, class Alloc>
template<class Pointer >
void boost::circular_buffer< T, Alloc >::decrement ( Pointer &  p) const
inlineprivate

Decrement the pointer.

◆ destroy()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::destroy ( )
inlineprivate

Destroy content and free allocated memory.

◆ destroy_content()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::destroy_content ( )
inlineprivate

Destroy the whole content of the circular buffer.

◆ destroy_if_constructed()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::destroy_if_constructed ( pointer  pos)
inlineprivate

Destroy an item only if it has been constructed.

◆ destroy_item()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::destroy_item ( pointer  p)
inlineprivate

Destroy an item.

◆ empty()

template<class T, class Alloc>
bool boost::circular_buffer< T, Alloc >::empty ( ) const
inline

Is the circular_buffer empty?

Returns
true if there are no elements stored in the circular_buffer; false otherwise.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
full()

◆ end() [1/2]

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::end ( void  )
inline

Get the iterator pointing to the end of the circular_buffer.

Returns
A random access iterator pointing to the element "one behind" the last element of the circular_buffer. If the circular_buffer is empty it returns an iterator equal to the one returned by begin().
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
begin(), rbegin(), rend()

◆ end() [2/2]

template<class T, class Alloc>
const_iterator boost::circular_buffer< T, Alloc >::end ( void  ) const
inline

Get the const iterator pointing to the end of the circular_buffer.

Returns
A const random access iterator pointing to the element "one behind" the last element of the circular_buffer. If the circular_buffer is empty it returns an iterator equal to the one returned by begin() const const.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
begin() const, rbegin() const, rend() const

◆ erase() [1/2]

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::erase ( iterator  pos)
inline

Remove an element at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer (but not an end()).
Postcondition
The element at the position pos is removed.
Parameters
posAn iterator pointing at the element to be removed.
Returns
Iterator to the first element remaining beyond the removed element or end() if no such element exists.
Exceptions
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the erased element and iterators pointing to the elements behind the erased element (towards the end; except iterators equal to end()).
Complexity
Linear (in std::distance(pos, end())).
See also
erase(iterator, iterator), rerase(iterator), rerase(iterator, iterator), clear()

◆ erase() [2/2]

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::erase ( iterator  first,
iterator  last 
)
inline

Erase the range [first, last).

Precondition
Valid range [first, last).
Postcondition
The elements from the range [first, last) are removed. (If first == last nothing is removed.)
Parameters
firstThe beginning of the range to be removed.
lastThe end of the range to be removed.
Returns
Iterator to the first element remaining beyond the removed elements or end() if no such element exists.
Exceptions
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the erased elements and iterators pointing to the elements behind the erased range (towards the end; except iterators equal to end()).
Complexity
Linear (in std::distance(first, end())).
See also
erase(iterator), rerase(iterator), rerase(iterator, iterator), clear()

◆ front() [1/2]

template<class T, class Alloc>
reference boost::circular_buffer< T, Alloc >::front ( void  )
inline

Get the first element.

Precondition
!empty()
Returns
A reference to the first element of the circular_buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
back()

◆ front() [2/2]

template<class T, class Alloc>
return_value_type boost::circular_buffer< T, Alloc >::front ( void  ) const
inline

Get the first element.

Precondition
!empty()
Returns
A const reference to the first element of the circular_buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
back() const

◆ full()

template<class T, class Alloc>
bool boost::circular_buffer< T, Alloc >::full ( ) const
inline

Is the circular_buffer full?

Returns
true if the number of elements stored in the circular_buffer equals the capacity of the circular_buffer; false otherwise.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
empty()

◆ get_allocator() [1/2]

template<class T, class Alloc>
allocator_type boost::circular_buffer< T, Alloc >::get_allocator ( ) const
inline

Get the allocator.

Returns
The allocator.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
get_allocator() for obtaining an allocator reference.

◆ get_allocator() [2/2]

template<class T, class Alloc>
allocator_type& boost::circular_buffer< T, Alloc >::get_allocator ( void  )
inline

Get the allocator reference.

Returns
A reference to the allocator.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
Note
This method was added in order to optimize obtaining of the allocator with a state, although use of stateful allocators in STL is discouraged.
See also
get_allocator() const

◆ increment()

template<class T, class Alloc>
template<class Pointer >
void boost::circular_buffer< T, Alloc >::increment ( Pointer &  p) const
inlineprivate

Increment the pointer.

◆ initialize() [1/11]

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::initialize ( capacity_type  capacity)
inlineprivate

Initialize the circular buffer.

◆ initialize() [2/11]

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::initialize ( capacity_type  capacity,
param_value_type  item 
)
inlineprivate

Initialize the circular buffer.

◆ initialize() [3/11]

template<class T, class Alloc>
template<class IntegralType >
void boost::circular_buffer< T, Alloc >::initialize ( IntegralType  n,
IntegralType  item,
const true_type &   
)
inlineprivate

Specialized initialize method.

◆ initialize() [4/11]

template<class T, class Alloc>
template<class Iterator >
void boost::circular_buffer< T, Alloc >::initialize ( Iterator  first,
Iterator  last,
const false_type &   
)
inlineprivate

Specialized initialize method.

◆ initialize() [5/11]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::initialize ( InputIterator  first,
InputIterator  last,
const std::input_iterator_tag &   
)
inlineprivate

Specialized initialize method.

◆ initialize() [6/11]

template<class T, class Alloc>
template<class ForwardIterator >
void boost::circular_buffer< T, Alloc >::initialize ( ForwardIterator  first,
ForwardIterator  last,
const std::forward_iterator_tag &   
)
inlineprivate

Specialized initialize method.

◆ initialize() [7/11]

template<class T, class Alloc>
template<class IntegralType >
void boost::circular_buffer< T, Alloc >::initialize ( capacity_type  capacity,
IntegralType  n,
IntegralType  item,
const true_type &   
)
inlineprivate

Specialized initialize method.

◆ initialize() [8/11]

template<class T, class Alloc>
template<class Iterator >
void boost::circular_buffer< T, Alloc >::initialize ( capacity_type  capacity,
Iterator  first,
Iterator  last,
const false_type &   
)
inlineprivate

Specialized initialize method.

◆ initialize() [9/11]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::initialize ( capacity_type  capacity,
InputIterator  first,
InputIterator  last,
const std::input_iterator_tag &   
)
inlineprivate

Specialized initialize method.

◆ initialize() [10/11]

template<class T, class Alloc>
template<class ForwardIterator >
void boost::circular_buffer< T, Alloc >::initialize ( capacity_type  capacity,
ForwardIterator  first,
ForwardIterator  last,
const std::forward_iterator_tag &   
)
inlineprivate

Specialized initialize method.

◆ initialize() [11/11]

template<class T, class Alloc>
template<class ForwardIterator >
void boost::circular_buffer< T, Alloc >::initialize ( capacity_type  capacity,
ForwardIterator  first,
ForwardIterator  last,
size_type  distance 
)
inlineprivate

Helper initialize method.

◆ insert() [1/7]

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::insert ( iterator  pos,
param_value_type  item = value_type() 
)
inline

Insert an element at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer or its end.
Postcondition
The item will be inserted at the position pos.
If the circular_buffer is full, the first element will be overwritten. If the circular_buffer is full and the pos points to begin(), then the item will not be inserted. If the capacity is 0, nothing will be inserted.
Parameters
posAn iterator specifying the position where the item will be inserted.
itemThe element to be inserted.
Returns
Iterator to the inserted element or begin() if the item is not inserted. (See the Effect.)
Exceptions
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the elements at the insertion point (including pos) and iterators behind the insertion point (towards the end; except iterators equal to end()). It also invalidates iterators pointing to the overwritten element.
Complexity
Linear (in std::distance(pos, end())).
See also
insert(iterator, size_type, value_type), insert(iterator, InputIterator, InputIterator), rinsert(iterator, value_type), rinsert(iterator, size_type, value_type), rinsert(iterator, InputIterator, InputIterator)

◆ insert() [2/7]

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::insert ( iterator  pos,
size_type  n,
param_value_type  item 
)
inline

Insert n copies of the item at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer or its end.
Postcondition
The number of min[n, (pos - begin()) + reserve()] elements will be inserted at the position pos.
The number of min[pos - begin(), max[0, n - reserve()]] elements will be overwritten at the beginning of the circular_buffer.
(See Example for the explanation.)
Parameters
posAn iterator specifying the position where the items will be inserted.
nThe number of items the to be inserted.
itemThe element whose copies will be inserted.
Exceptions
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the elements at the insertion point (including pos) and iterators behind the insertion point (towards the end; except iterators equal to end()). It also invalidates iterators pointing to the overwritten elements.
Complexity
Linear (in min[capacity(), std::distance(pos, end()) + n]).
Example
Consider a circular_buffer with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.

|1|2|3|4| | |
p —^

After inserting 5 elements at the position p:

insert(p, (size_t)5, 0);

actually only 4 elements get inserted and elements 1 and 2 are overwritten. This is due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks like this:

|0|0|0|0|3|4|

For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|0|0|0|0|0|3|4|.
See also
insert(iterator, value_type), insert(iterator, InputIterator, InputIterator), rinsert(iterator, value_type), rinsert(iterator, size_type, value_type), rinsert(iterator, InputIterator, InputIterator)

◆ insert() [3/7]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::insert ( iterator  pos,
InputIterator  first,
InputIterator  last 
)
inline

Insert the range [first, last) at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer or its end.
Valid range [first, last) where first and last meet the requirements of an InputIterator.
Postcondition
Elements from the range [first + max[0, distance(first, last) - (pos - begin()) - reserve()], last) will be inserted at the position pos.
The number of min[pos - begin(), max[0, distance(first, last) - reserve()]] elements will be overwritten at the beginning of the circular_buffer.
(See Example for the explanation.)
Parameters
posAn iterator specifying the position where the range will be inserted.
firstThe beginning of the range to be inserted.
lastThe end of the range to be inserted.
Exceptions
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the elements at the insertion point (including pos) and iterators behind the insertion point (towards the end; except iterators equal to end()). It also invalidates iterators pointing to the overwritten elements.
Complexity
Linear (in [std::distance(pos, end()) + std::distance(first, last)]; in min[capacity(), std::distance(pos, end()) + std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
Example
Consider a circular_buffer with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.

|1|2|3|4| | |
p —^

After inserting a range of elements at the position p:

int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);

actually only elements 6, 7, 8 and 9 from the specified range get inserted and elements 1 and 2 are overwritten. This is due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks like this:

|6|7|8|9|3|4|

For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|5|6|7|8|9|3|4|.
See also
insert(iterator, value_type), insert(iterator, size_type, value_type), rinsert(iterator, value_type), rinsert(iterator, size_type, value_type), rinsert(iterator, InputIterator, InputIterator)

◆ insert() [4/7]

template<class T, class Alloc>
template<class IntegralType >
void boost::circular_buffer< T, Alloc >::insert ( const iterator pos,
IntegralType  n,
IntegralType  item,
const true_type &   
)
inlineprivate

Specialized insert method.

◆ insert() [5/7]

template<class T, class Alloc>
template<class Iterator >
void boost::circular_buffer< T, Alloc >::insert ( const iterator pos,
Iterator  first,
Iterator  last,
const false_type &   
)
inlineprivate

Specialized insert method.

◆ insert() [6/7]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::insert ( iterator  pos,
InputIterator  first,
InputIterator  last,
const std::input_iterator_tag &   
)
inlineprivate

Specialized insert method.

◆ insert() [7/7]

template<class T, class Alloc>
template<class ForwardIterator >
void boost::circular_buffer< T, Alloc >::insert ( const iterator pos,
ForwardIterator  first,
ForwardIterator  last,
const std::forward_iterator_tag &   
)
inlineprivate

Specialized insert method.

◆ insert_item()

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::insert_item ( const iterator pos,
param_value_type  item 
)
inlineprivate

Helper insert method.

◆ insert_n()

template<class T, class Alloc>
template<class Wrapper >
void boost::circular_buffer< T, Alloc >::insert_n ( const iterator pos,
size_type  n,
const Wrapper &  wrapper 
)
inlineprivate

Helper insert method.

◆ is_uninitialized()

template<class T, class Alloc>
bool boost::circular_buffer< T, Alloc >::is_uninitialized ( const_pointer  p) const
inlineprivate

Does the pointer point to the uninitialized memory?

◆ linearize()

template<class T, class Alloc>
pointer boost::circular_buffer< T, Alloc >::linearize ( )
inline

Linearize the internal buffer into a continuous array.

This method can be useful when passing the stored data into a legacy C API as an array.

Postcondition
&(*this)[0] < &(*this)[1] < ... < &(*this)[size() - 1]
Returns
A pointer to the beginning of the array or 0 if empty.
Exceptions
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()); does not invalidate any iterators if the postcondition (the Effect) is already met prior calling this method.
Complexity
Linear (in the size of the circular_buffer); constant if the postcondition (the Effect) is already met.
Warning
In general invoking any method which modifies the internal state of the circular_buffer may delinearize the internal buffer and invalidate the returned pointer.
See also
array_one() and array_two() for the other option how to pass data into a legacy C hidapi API.

◆ map_pointer()

template<class T, class Alloc>
pointer boost::circular_buffer< T, Alloc >::map_pointer ( pointer  p) const
inlineprivate

Map the null pointer to virtual end of circular buffer.

◆ max_size()

template<class T, class Alloc>
size_type boost::circular_buffer< T, Alloc >::max_size ( void  ) const
inline

Get the largest possible size or capacity of the circular_buffer. (It depends on allocator's max_size()).

Returns
The maximum size/capacity the circular_buffer can be set to.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
size(), capacity(), reserve()

◆ operator=()

template<class T, class Alloc>
circular_buffer<T, Alloc>& boost::circular_buffer< T, Alloc >::operator= ( const circular_buffer< T, Alloc > &  cb)
inline

The assign operator.

Makes this circular_buffer to become a copy of the specified circular_buffer.

Postcondition
*this == cb
Parameters
cbThe circular_buffer to be copied.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Strong.
Iterator Invalidation
Invalidates all iterators pointing to this circular_buffer (except iterators equal to end()).
Complexity
Linear (in the size of cb).
See also
assign(size_type, const_reference), assign(capacity_type, size_type, const_reference), assign(InputIterator, InputIterator), assign(capacity_type, InputIterator, InputIterator)

◆ operator[]() [1/2]

template<class T, class Alloc>
reference boost::circular_buffer< T, Alloc >::operator[] ( size_type  index)
inline

Get the element at the index position.

Precondition
0 <= index && index < size()
Parameters
indexThe position of the element.
Returns
A reference to the element at the index position.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
at()

◆ operator[]() [2/2]

template<class T, class Alloc>
return_value_type boost::circular_buffer< T, Alloc >::operator[] ( size_type  index) const
inline

Get the element at the index position.

Precondition
0 <= index && index < size()
Parameters
indexThe position of the element.
Returns
A const reference to the element at the index position.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
at() const

◆ pop_back()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::pop_back ( )
inline

Remove the last element from the circular_buffer.

Precondition
!empty()
Postcondition
The last element is removed from the circular_buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Invalidates only iterators pointing to the removed element.
Complexity
Constant (in the size of the circular_buffer).
See also
pop_front(), push_back(const_reference), push_front(const_reference)

◆ pop_front()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::pop_front ( void  )
inline

Remove the first element from the circular_buffer.

Precondition
!empty()
Postcondition
The first element is removed from the circular_buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Invalidates only iterators pointing to the removed element.
Complexity
Constant (in the size of the circular_buffer).
See also
pop_back(), push_back(const_reference), push_front(const_reference)

◆ push_back()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::push_back ( param_value_type  item = value_type())
inline

Insert a new element at the end of the circular_buffer.

Postcondition
if capacity() > 0 then back() == item
If the circular_buffer is full, the first element will be removed. If the capacity is 0, nothing will be inserted.
Parameters
itemThe element to be inserted.
Exceptions
WhateverT::T(const T&) throws.
Exception Safety
Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation
Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
Complexity
Constant (in the size of the circular_buffer).
See also
push_front(const_reference), pop_back(), pop_front()

◆ push_front()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::push_front ( param_value_type  item = value_type())
inline

Insert a new element at the beginning of the circular_buffer.

Postcondition
if capacity() > 0 then front() == item
If the circular_buffer is full, the last element will be removed. If the capacity is 0, nothing will be inserted.
Parameters
itemThe element to be inserted.
Exceptions
WhateverT::T(const T&) throws.
Exception Safety
Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation
Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
Complexity
Constant (in the size of the circular_buffer).
See also
push_back(const_reference), pop_back(), pop_front()

◆ rbegin() [1/2]

template<class T, class Alloc>
reverse_iterator boost::circular_buffer< T, Alloc >::rbegin ( void  )
inline

Get the iterator pointing to the beginning of the "reversed" circular_buffer.

Returns
A reverse random access iterator pointing to the last element of the circular_buffer. If the circular_buffer is empty it returns an iterator equal to the one returned by rend().
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
rend(), begin(), end()

◆ rbegin() [2/2]

template<class T, class Alloc>
const_reverse_iterator boost::circular_buffer< T, Alloc >::rbegin ( void  ) const
inline

Get the const iterator pointing to the beginning of the "reversed" circular_buffer.

Returns
A const reverse random access iterator pointing to the last element of the circular_buffer. If the circular_buffer is empty it returns an iterator equal to the one returned by rend() const.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
rend() const, begin() const, end() const

◆ rend() [1/2]

template<class T, class Alloc>
reverse_iterator boost::circular_buffer< T, Alloc >::rend ( void  )
inline

Get the iterator pointing to the end of the "reversed" circular_buffer.

Returns
A reverse random access iterator pointing to the element "one before" the first element of the circular_buffer. If the circular_buffer is empty it returns an iterator equal to the one returned by rbegin().
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
rbegin(), begin(), end()

◆ rend() [2/2]

template<class T, class Alloc>
const_reverse_iterator boost::circular_buffer< T, Alloc >::rend ( void  ) const
inline

Get the const iterator pointing to the end of the "reversed" circular_buffer.

Returns
A const reverse random access iterator pointing to the element "one before" the first element of the circular_buffer. If the circular_buffer is empty it returns an iterator equal to the one returned by rbegin() const.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
rbegin() const, begin() const, end() const

◆ replace()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::replace ( pointer  pos,
param_value_type  item 
)
inlineprivate

Replace an element.

◆ rerase() [1/2]

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::rerase ( iterator  pos)
inline

Remove an element at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer (but not an end()).
Postcondition
The element at the position pos is removed.
Parameters
posAn iterator pointing at the element to be removed.
Returns
Iterator to the first element remaining in front of the removed element or begin() if no such element exists.
Exceptions
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the erased element and iterators pointing to the elements in front of the erased element (towards the beginning).
Complexity
Linear (in std::distance(begin(), pos)).
Note
This method is symetric to the erase(iterator) method and is more effective than erase(iterator) if the iterator pos is close to the beginning of the circular_buffer. (See the Complexity.)
See also
erase(iterator), erase(iterator, iterator), rerase(iterator, iterator), clear()

◆ rerase() [2/2]

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::rerase ( iterator  first,
iterator  last 
)
inline

Erase the range [first, last).

Precondition
Valid range [first, last).
Postcondition
The elements from the range [first, last) are removed. (If first == last nothing is removed.)
Parameters
firstThe beginning of the range to be removed.
lastThe end of the range to be removed.
Returns
Iterator to the first element remaining in front of the removed elements or begin() if no such element exists.
Exceptions
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the erased elements and iterators pointing to the elements in front of the erased range (towards the beginning).
Complexity
Linear (in std::distance(begin(), last)).
Note
This method is symetric to the erase(iterator, iterator) method and is more effective than erase(iterator, iterator) if std::distance(begin(), first) is lower that std::distance(last, end()).
See also
erase(iterator), erase(iterator, iterator), rerase(iterator), clear()

◆ reserve()

template<class T, class Alloc>
size_type boost::circular_buffer< T, Alloc >::reserve ( ) const
inline

Get the maximum number of elements which can be inserted into the circular_buffer without overwriting any of already stored elements.

Returns
capacity() - size()
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
capacity(), size(), max_size()

◆ reset()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::reset ( pointer  buff,
pointer  last,
capacity_type  new_capacity 
)
inlineprivate

Reset the circular buffer.

◆ resize()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::resize ( size_type  new_size,
param_value_type  item = value_type() 
)
inline

Change the size of the circular_buffer.

Postcondition
size() == new_size && capacity() >= new_size

If the new size is greater than the current size, copies of item will be inserted at the back of the of the circular_buffer in order to achieve the desired size. In the case the resulting size exceeds the current capacity the capacity will be set to new_size.
If the current number of elements stored in the circular_buffer is greater than the desired new size then number of [size() - new_size] last elements will be removed. (The capacity will remain unchanged.)
Parameters
new_sizeThe new size.
itemThe element the circular_buffer will be filled with in order to gain the requested size. (See the Effect.)
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()) if the new size is greater than the current capacity. Invalidates iterators pointing to the removed elements if the new size is lower that the original size. Otherwise it does not invalidate any iterator.
Complexity
Linear (in the new size of the circular_buffer).
See also
rresize(size_type, const_reference), set_capacity(capacity_type)

◆ rinsert() [1/7]

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::rinsert ( iterator  pos,
param_value_type  item = value_type() 
)
inline

Insert an element before the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer or its end.
Postcondition
The item will be inserted before the position pos.
If the circular_buffer is full, the last element will be overwritten. If the circular_buffer is full and the pos points to end(), then the item will not be inserted. If the capacity is 0, nothing will be inserted.
Parameters
posAn iterator specifying the position before which the item will be inserted.
itemThe element to be inserted.
Returns
Iterator to the inserted element or end() if the item is not inserted. (See the Effect.)
Exceptions
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the elements before the insertion point (towards the beginning and excluding pos). It also invalidates iterators pointing to the overwritten element.
Complexity
Linear (in std::distance(begin(), pos)).
See also
rinsert(iterator, size_type, value_type), rinsert(iterator, InputIterator, InputIterator), insert(iterator, value_type), insert(iterator, size_type, value_type), insert(iterator, InputIterator, InputIterator)

◆ rinsert() [2/7]

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::rinsert ( iterator  pos,
size_type  n,
param_value_type  item 
)
inline

Insert n copies of the item before the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer or its end.
Postcondition
The number of min[n, (end() - pos) + reserve()] elements will be inserted before the position pos.
The number of min[end() - pos, max[0, n - reserve()]] elements will be overwritten at the end of the circular_buffer.
(See Example for the explanation.)
Parameters
posAn iterator specifying the position where the items will be inserted.
nThe number of items the to be inserted.
itemThe element whose copies will be inserted.
Exceptions
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the elements before the insertion point (towards the beginning and excluding pos). It also invalidates iterators pointing to the overwritten elements.
Complexity
Linear (in min[capacity(), std::distance(begin(), pos) + n]).
Example
Consider a circular_buffer with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.

|1|2|3|4| | |
p —^

After inserting 5 elements before the position p:

rinsert(p, (size_t)5, 0);

actually only 4 elements get inserted and elements 3 and 4 are overwritten. This is due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks like this:

|1|2|0|0|0|0|

For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|0|0|0|0|0|3|4|.
See also
rinsert(iterator, value_type), rinsert(iterator, InputIterator, InputIterator), insert(iterator, value_type), insert(iterator, size_type, value_type), insert(iterator, InputIterator, InputIterator)

◆ rinsert() [3/7]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::rinsert ( iterator  pos,
InputIterator  first,
InputIterator  last 
)
inline

Insert the range [first, last) before the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer or its end.
Valid range [first, last) where first and last meet the requirements of an InputIterator.
Postcondition
Elements from the range [first, last - max[0, distance(first, last) - (end() - pos) - reserve()]) will be inserted before the position pos.
The number of min[end() - pos, max[0, distance(first, last) - reserve()]] elements will be overwritten at the end of the circular_buffer.
(See Example for the explanation.)
Parameters
posAn iterator specifying the position where the range will be inserted.
firstThe beginning of the range to be inserted.
lastThe end of the range to be inserted.
Exceptions
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation
Invalidates iterators pointing to the elements before the insertion point (towards the beginning and excluding pos). It also invalidates iterators pointing to the overwritten elements.
Complexity
Linear (in [std::distance(begin(), pos) + std::distance(first, last)]; in min[capacity(), std::distance(begin(), pos) + std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
Example
Consider a circular_buffer with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.

|1|2|3|4| | |
p —^

After inserting a range of elements before the position p:

int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);

actually only elements 5, 6, 7 and 8 from the specified range get inserted and elements 3 and 4 are overwritten. This is due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks like this:

|1|2|5|6|7|8|

For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|5|6|7|8|9|3|4|.
See also
rinsert(iterator, value_type), rinsert(iterator, size_type, value_type), insert(iterator, value_type), insert(iterator, size_type, value_type), insert(iterator, InputIterator, InputIterator)

◆ rinsert() [4/7]

template<class T, class Alloc>
template<class IntegralType >
void boost::circular_buffer< T, Alloc >::rinsert ( const iterator pos,
IntegralType  n,
IntegralType  item,
const true_type &   
)
inlineprivate

Specialized rinsert method.

◆ rinsert() [5/7]

template<class T, class Alloc>
template<class Iterator >
void boost::circular_buffer< T, Alloc >::rinsert ( const iterator pos,
Iterator  first,
Iterator  last,
const false_type &   
)
inlineprivate

Specialized rinsert method.

◆ rinsert() [6/7]

template<class T, class Alloc>
template<class InputIterator >
void boost::circular_buffer< T, Alloc >::rinsert ( iterator  pos,
InputIterator  first,
InputIterator  last,
const std::input_iterator_tag &   
)
inlineprivate

Specialized insert method.

◆ rinsert() [7/7]

template<class T, class Alloc>
template<class ForwardIterator >
void boost::circular_buffer< T, Alloc >::rinsert ( const iterator pos,
ForwardIterator  first,
ForwardIterator  last,
const std::forward_iterator_tag &   
)
inlineprivate

Specialized rinsert method.

◆ rinsert_n()

template<class T, class Alloc>
template<class Wrapper >
void boost::circular_buffer< T, Alloc >::rinsert_n ( const iterator pos,
size_type  n,
const Wrapper &  wrapper 
)
inlineprivate

Helper rinsert method.

◆ rresize()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::rresize ( size_type  new_size,
param_value_type  item = value_type() 
)
inline

Change the size of the circular_buffer.

Postcondition
size() == new_size && capacity() >= new_size

If the new size is greater than the current size, copies of item will be inserted at the front of the of the circular_buffer in order to achieve the desired size. In the case the resulting size exceeds the current capacity the capacity will be set to new_size.
If the current number of elements stored in the circular_buffer is greater than the desired new size then number of [size() - new_size] first elements will be removed. (The capacity will remain unchanged.)
Parameters
new_sizeThe new size.
itemThe element the circular_buffer will be filled with in order to gain the requested size. (See the Effect.)
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()) if the new size is greater than the current capacity. Invalidates iterators pointing to the removed elements if the new size is lower that the original size. Otherwise it does not invalidate any iterator.
Complexity
Linear (in the new size of the circular_buffer).
See also
resize(size_type, const_reference), rset_capacity(capacity_type)

◆ rset_capacity()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::rset_capacity ( capacity_type  new_capacity)
inline

Change the capacity of the circular_buffer.

Postcondition
capacity() == new_capacity && size() <= new_capacity

If the current number of elements stored in the circular_buffer is greater than the desired new capacity then number of [size() - new_capacity] first elements will be removed and the new size will be equal to new_capacity.
Parameters
new_capacityThe new capacity.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Strong.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()) if the new capacity is different from the original.
Complexity
Linear (in min[size(), new_capacity]).
See also
set_capacity(capacity_type), rresize(size_type, const_reference)

◆ set_capacity()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::set_capacity ( capacity_type  new_capacity)
inline

Change the capacity of the circular_buffer.

Postcondition
capacity() == new_capacity && size() <= new_capacity

If the current number of elements stored in the circular_buffer is greater than the desired new capacity then number of [size() - new_capacity] last elements will be removed and the new size will be equal to new_capacity.
Parameters
new_capacityThe new capacity.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Strong.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer (except iterators equal to end()) if the new capacity is different from the original.
Complexity
Linear (in min[size(), new_capacity]).
See also
rset_capacity(capacity_type), resize(size_type, const_reference)

◆ size()

template<class T, class Alloc>
size_type boost::circular_buffer< T, Alloc >::size ( void  ) const
inline

Get the number of elements currently stored in the circular_buffer.

Returns
The number of elements stored in the circular_buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer).
See also
capacity(), max_size(), reserve(), resize(size_type, const_reference)

◆ sub()

template<class T, class Alloc>
template<class Pointer >
Pointer boost::circular_buffer< T, Alloc >::sub ( Pointer  p,
difference_type  n 
) const
inlineprivate

Subtract n from the pointer.

◆ swap()

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::swap ( circular_buffer< T, Alloc > &  cb)
inline

Swap the contents of two circular_buffers.

Postcondition
this contains elements of cb and vice versa; the capacity of this equals to the capacity of cb and vice versa.
Parameters
cbThe circular_buffer whose content will be swapped.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Invalidates all iterators of both circular_buffers. (On the other hand the iterators still point to the same elements but within another container. If you want to rely on this feature you have to turn the Debug Support off otherwise an assertion will report an error if such invalidated iterator is used.)
Complexity
Constant (in the size of the circular_buffer).
See also
swap(circular_buffer<T, Alloc>&, circular_buffer<T, Alloc>&)

◆ swap_allocator() [1/2]

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::swap_allocator ( circular_buffer< T, Alloc > &  cb,
const true_type &   
)
inlineprivate

Specialized method for swapping the allocator.

◆ swap_allocator() [2/2]

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::swap_allocator ( circular_buffer< T, Alloc > &  cb,
const false_type &   
)
inlineprivate

Specialized method for swapping the allocator.

Friends And Related Function Documentation

◆ cb_details::iterator

template<class T, class Alloc>
template<class Buff , class Traits >
friend struct cb_details::iterator
friend

Member Data Documentation

◆ m_alloc

template<class T, class Alloc>
allocator_type boost::circular_buffer< T, Alloc >::m_alloc
private

The allocator.

◆ m_buff

template<class T, class Alloc>
pointer boost::circular_buffer< T, Alloc >::m_buff
private

The internal buffer used for storing elements in the circular buffer.

◆ m_end

template<class T, class Alloc>
pointer boost::circular_buffer< T, Alloc >::m_end
private

The internal buffer's end (end of the storage space).

◆ m_first

template<class T, class Alloc>
pointer boost::circular_buffer< T, Alloc >::m_first
private

The virtual beginning of the circular buffer.

◆ m_last

template<class T, class Alloc>
pointer boost::circular_buffer< T, Alloc >::m_last
private

The virtual end of the circular buffer (one behind the last element).

◆ m_size

template<class T, class Alloc>
size_type boost::circular_buffer< T, Alloc >::m_size
private

The number of items currently stored in the circular buffer.


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