|
emlabcpp
modern opinionated embedded C++ library
|
Class implementing circular buffer of any type for up to N elements. More...
#include <static_circular_buffer.h>
Public Types | |
| using | index_type = typename Strategy::index_type |
| using | size_type = typename Strategy::size_type |
| using | value_type = T |
| using | reference = T & |
| using | const_reference = T const & |
| using | iterator = static_circular_buffer_iterator< T > |
| using | const_iterator = static_circular_buffer_iterator< T const > |
Public Member Functions | |
| static_circular_buffer () noexcept=default | |
| Default constructed circular buffer is empty. More... | |
| static_circular_buffer (static_circular_buffer const &other) | |
| static_circular_buffer (static_circular_buffer &&other) noexcept | |
| static_circular_buffer & | operator= (static_circular_buffer const &other) |
| Clears the buffer by destructing all contained elements and copies from other buffer. More... | |
| static_circular_buffer & | operator= (static_circular_buffer &&other) noexcept |
| Clears the buffer by destructing all contained elements and moves from other buffer. More... | |
| iterator | begin () noexcept |
| Iterator to first element. More... | |
| const_iterator | begin () const noexcept |
| Iterator to first element. More... | |
| std::reverse_iterator< iterator > | rbegin () noexcept |
| Reverse iterator to last element. More... | |
| std::reverse_iterator< const_iterator > | rbegin () const noexcept |
| Reverse iterator to last element. More... | |
| reference | front () noexcept |
| Reference to first element. More... | |
| const_reference | front () const noexcept |
| Reference to first element. More... | |
| T | take_front () |
| Removes and returns first element, is safe in SPSC scenario. More... | |
| void | take_front (auto &&buffer) |
| Removes and moves first n elements into provided buffer, is safe in SPSC scenario. More... | |
| void | pop_front () |
| Removes first element, is safe in SPSC scenario. More... | |
| void | pop_front (size_type n) |
| Removes first n elements, is safe in SPSC scenario. More... | |
| iterator | end () noexcept |
| Iterator to one-past-last element. More... | |
| const_iterator | end () const noexcept |
| Iterator to one-past-last element. More... | |
| std::reverse_iterator< iterator > | rend () noexcept |
| Reverse iterator to one-before-first element. More... | |
| std::reverse_iterator< const_iterator > | rend () const noexcept |
| Reverse iterator to one-before-first element. More... | |
| reference | back () noexcept |
| Reference to last element. More... | |
| const_reference | back () const noexcept |
| Reference to last element. More... | |
| void | push_back (T item) |
| Inserts item at the back, is safe in SPSC scenario. More... | |
| template<typename... Args> | |
| T & | emplace_back (Args &&... args) |
| Inserts item constructed with args... at the back, is safe in SPSC scenario. More... | |
| void | copy_range_back (auto &&range) |
| Inserts range by copy at the back, is safe in SPSC scenario. More... | |
| void | move_range_back (auto &&range) |
| Inserts range by move at the back, is safe in SPSC scenario. More... | |
| constexpr size_type | capacity () const noexcept |
| Returns maximum capacity of the buffer. More... | |
| size_type | size () const |
| Returns current size of the buffer. More... | |
| bool | empty () const noexcept |
| Returns whether the buffer is empty. More... | |
| bool | full () const noexcept |
| Returns whether the buffer is full. More... | |
| void | clear () |
| Clears the buffer by destructing all contained elements. More... | |
| ~static_circular_buffer () | |
| Destructor destructs all contained elements. More... | |
Static Public Attributes | |
| static constexpr std::size_t | max_size = Strategy::max_size |
Friends | |
| template<typename U > | |
| class | static_circular_buffer_iterator |
Class implementing circular buffer of any type for up to N elements.
It is safe in "single consumer single producer" scenario between main loop and interrupts. Because of that the behavior is as follows:
| using emlabcpp::static_circular_buffer< T, N, Strategy >::const_iterator = static_circular_buffer_iterator< T const > |
| using emlabcpp::static_circular_buffer< T, N, Strategy >::const_reference = T const& |
| using emlabcpp::static_circular_buffer< T, N, Strategy >::index_type = typename Strategy::index_type |
| using emlabcpp::static_circular_buffer< T, N, Strategy >::iterator = static_circular_buffer_iterator< T > |
| using emlabcpp::static_circular_buffer< T, N, Strategy >::reference = T& |
| using emlabcpp::static_circular_buffer< T, N, Strategy >::size_type = typename Strategy::size_type |
| using emlabcpp::static_circular_buffer< T, N, Strategy >::value_type = T |
|
defaultnoexcept |
Default constructed circular buffer is empty.
|
inline |
|
inlinenoexcept |
|
inline |
Destructor destructs all contained elements.
|
inlinenoexcept |
Reference to last element.
|
inlinenoexcept |
Reference to last element.
|
inlinenoexcept |
Iterator to first element.
References emlabcpp::protocol::max_size.
|
inlinenoexcept |
Iterator to first element.
References emlabcpp::protocol::max_size.
|
inlineconstexprnoexcept |
Returns maximum capacity of the buffer.
References emlabcpp::N.
|
inline |
Clears the buffer by destructing all contained elements.
|
inline |
Inserts range by copy at the back, is safe in SPSC scenario.
References emlabcpp::protocol::max_size, and emlabcpp::range().
|
inline |
Inserts item constructed with args... at the back, is safe in SPSC scenario.
References emlabcpp::args.
|
inlinenoexcept |
Returns whether the buffer is empty.
|
inlinenoexcept |
Iterator to one-past-last element.
References emlabcpp::protocol::max_size.
|
inlinenoexcept |
Iterator to one-past-last element.
References emlabcpp::protocol::max_size.
|
inlinenoexcept |
Reference to first element.
|
inlinenoexcept |
Reference to first element.
|
inlinenoexcept |
Returns whether the buffer is full.
|
inline |
Inserts range by move at the back, is safe in SPSC scenario.
References emlabcpp::protocol::max_size, and emlabcpp::range().
|
inlinenoexcept |
Clears the buffer by destructing all contained elements and moves from other buffer.
|
inline |
Clears the buffer by destructing all contained elements and copies from other buffer.
|
inline |
Removes first element, is safe in SPSC scenario.
|
inline |
Removes first n elements, is safe in SPSC scenario.
References emlabcpp::protocol::max_size.
|
inline |
Inserts item at the back, is safe in SPSC scenario.
|
inlinenoexcept |
Reverse iterator to last element.
|
inlinenoexcept |
Reverse iterator to last element.
|
inlinenoexcept |
Reverse iterator to one-before-first element.
|
inlinenoexcept |
Reverse iterator to one-before-first element.
|
inline |
Returns current size of the buffer.
|
inline |
Removes and returns first element, is safe in SPSC scenario.
|
inline |
Removes and moves first n elements into provided buffer, is safe in SPSC scenario.
References emlabcpp::protocol::max_size.
|
friend |
|
staticconstexpr |