qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::detail::ring_buffer_iterator< T, N, C, Overwrite > Class Template Reference

Iterator for ring_buffer. More...

#include <ring_buffer.h>

Public Types

using self_type = ring_buffer_iterator<T, N, C, Overwrite>
using value_type = T
using reference = T &
using const_reference = T const &
using pointer = T *
using const_pointer = T const *
using size_type = size_t
using difference_type = ptrdiff_t
using iterator_category = std::forward_iterator_tag

Public Member Functions

 ring_buffer_iterator () noexcept=default
 Default constructor.
 ring_buffer_iterator (buffer_t source, size_type index, size_type count) noexcept
 Constructor with source buffer, current index, and count.
 ring_buffer_iterator (ring_buffer_iterator const &) noexcept=default
 Copy constructor.
ring_buffer_iteratoroperator= (ring_buffer_iterator const &) noexcept=default
 Copy assignment operator.
template<bool Z = C, typename std::enable_if<(!Z), int >::type * = nullptr>
reference operator* () noexcept
 Dereference operator (non-const version)
template<bool Z = C, typename std::enable_if<(Z), int >::type * = nullptr>
const_reference operator* () const noexcept
 Dereference operator (const version)
template<bool Z = C, typename std::enable_if<(!Z), int >::type * = nullptr>
reference operator-> () noexcept
 Arrow operator (non-const version)
template<bool Z = C, typename std::enable_if<(Z), int >::type * = nullptr>
const_reference operator-> () const noexcept
 Arrow operator (const version)
self_typeoperator++ () noexcept
 Pre-increment operator.
self_type operator++ (int) noexcept
 Post-increment operator.
size_type index () const noexcept
 Get the current index in the buffer.
size_type count () const noexcept
 Get the current count of accessed elements.
 ~ring_buffer_iterator ()=default
 Destructor.

Detailed Description

template<typename T, size_t N, bool C, bool Overwrite>
class qb::detail::ring_buffer_iterator< T, N, C, Overwrite >

Iterator for ring_buffer.

Template Parameters
TThe type of elements in the buffer
NThe capacity of the buffer
CWhether this is a const iterator (true) or non-const iterator (false)
OverwriteWhether to overwrite old elements when the buffer is full

Constructor & Destructor Documentation

◆ ring_buffer_iterator()

template<typename T, size_t N, bool C, bool Overwrite>
qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::ring_buffer_iterator ( buffer_t source,
size_type index,
size_type count )
inlinenoexcept

Constructor with source buffer, current index, and count.

Parameters
sourceThe source ring buffer
indexCurrent index in the buffer
countCurrent element count

Member Function Documentation

◆ operator*() [1/2]

template<typename T, size_t N, bool C, bool Overwrite>
template<bool Z = C, typename std::enable_if<(!Z), int >::type * = nullptr>
reference qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::operator* ( )
inlinenodiscardnoexcept

Dereference operator (non-const version)

Returns
Reference to the current element

◆ operator*() [2/2]

template<typename T, size_t N, bool C, bool Overwrite>
template<bool Z = C, typename std::enable_if<(Z), int >::type * = nullptr>
const_reference qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::operator* ( ) const
inlinenodiscardnoexcept

Dereference operator (const version)

Returns
Const reference to the current element

◆ operator->() [1/2]

template<typename T, size_t N, bool C, bool Overwrite>
template<bool Z = C, typename std::enable_if<(!Z), int >::type * = nullptr>
reference qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::operator-> ( )
inlinenodiscardnoexcept

Arrow operator (non-const version)

Returns
Pointer to the current element

◆ operator->() [2/2]

template<typename T, size_t N, bool C, bool Overwrite>
template<bool Z = C, typename std::enable_if<(Z), int >::type * = nullptr>
const_reference qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::operator-> ( ) const
inlinenodiscardnoexcept

Arrow operator (const version)

Returns
Const pointer to the current element

◆ operator++() [1/2]

template<typename T, size_t N, bool C, bool Overwrite>
self_type & qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::operator++ ( )
inlinenoexcept

Pre-increment operator.

Returns
Reference to this iterator after incrementing

◆ operator++() [2/2]

template<typename T, size_t N, bool C, bool Overwrite>
self_type qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::operator++ ( int )
inlinenodiscardnoexcept

Post-increment operator.

Returns
Copy of this iterator before incrementing

◆ index()

template<typename T, size_t N, bool C, bool Overwrite>
size_type qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::index ( ) const
inlinenodiscardnoexcept

Get the current index in the buffer.

Returns
The current index

◆ count()

template<typename T, size_t N, bool C, bool Overwrite>
size_type qb::detail::ring_buffer_iterator< T, N, C, Overwrite >::count ( ) const
inlinenodiscardnoexcept

Get the current count of accessed elements.

Returns
The current count