Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::circular_buffer< T, Capacity > Class Template Reference

A container with fixed capacity featuring constant time insertion and removal at opposite ends; i.e., with an interface similar to std::queue. The storage for the elements is held directly within the class. Storing more than Capacity elements results in overwriting the oldest element. More...

Inheritance diagram for arene::base::circular_buffer< T, Capacity >:
Inheritance graph

Public Member Functions

constexpr circular_buffer () noexcept
 Construct an empty queue.
 
template<typename Iterator, constraints< std::enable_if_t< arene::base::is_forward_iterator_v< Iterator > >, std::enable_if_t< std::is_constructible< value_type, typename std::iterator_traits< Iterator >::reference >::value > > = nullptr>
constexpr circular_buffer (Iterator in_begin, Iterator in_end) noexcept(noexcept(::arene::base::distance(in_begin, in_end)) &&std::is_nothrow_constructible< value_type, typename std::iterator_traits< Iterator >::reference >::value)
 Construct a queue from a range of elements, taken to be in front -> back order.
 
template<typename U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
constexpr circular_buffer (std::initializer_list< value_type > init) noexcept(noexcept(circular_buffer(init.begin(), init.end())))
 Construct a queue by copying from an initializer list of elements, taken to be in front -> back order.
 

Detailed Description

template<typename T, std::size_t Capacity>
class arene::base::circular_buffer< T, Capacity >

A container with fixed capacity featuring constant time insertion and removal at opposite ends; i.e., with an interface similar to std::queue. The storage for the elements is held directly within the class. Storing more than Capacity elements results in overwriting the oldest element.

Template Parameters
TThe type of each element
CapacityThe maximum number of elements that can be stored

Constructor & Destructor Documentation

◆ circular_buffer() [1/3]

template<typename T, std::size_t Capacity>
arene::base::circular_buffer< T, Capacity >::circular_buffer ( )
inlineconstexprnoexcept

Construct an empty queue.

◆ circular_buffer() [2/3]

template<typename T, std::size_t Capacity>
template<typename Iterator, constraints< std::enable_if_t< arene::base::is_forward_iterator_v< Iterator > >, std::enable_if_t< std::is_constructible< value_type, typename std::iterator_traits< Iterator >::reference >::value > > = nullptr>
arene::base::circular_buffer< T, Capacity >::circular_buffer ( Iterator in_begin,
Iterator in_end )
inlineconstexprnoexcept

Construct a queue from a range of elements, taken to be in front -> back order.

Template Parameters
IteratorThe type of the iterators to construct from
Parameters
in_beginAn iterator to the beginning (front) of the input range
in_endAn iterator to the end (back+1) of the input range
Precondition
distance(in_begin, in_end) >= 0 and <= capacity(), otherwise ARENE_PRECONDITION violation
If the behaviour of distance(in_begin, in_end) is undefined, then this function's behaviour is too

◆ circular_buffer() [3/3]

template<typename T, std::size_t Capacity>
template<typename U = value_type, constraints< std::enable_if_t< std::is_copy_constructible< U >::value > > = nullptr>
arene::base::circular_buffer< T, Capacity >::circular_buffer ( std::initializer_list< value_type > init)
inlineconstexprnoexcept

Construct a queue by copying from an initializer list of elements, taken to be in front -> back order.

Parameters
initAn initializer list of the value type
Precondition
init.size() <= capacity(), otherwise ARENE_PRECONDITION violation

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