Go to the documentation of this file.
9 #ifndef EAGINE_DOUBLE_BUFFER_HPP
10 #define EAGINE_DOUBLE_BUFFER_HPP
26 : _values{{initial, initial}} {}
37 return _idx ? _values.back() : _values.front();
41 auto front() const noexcept -> const T& {
42 return _idx ? _values.back() : _values.front();
46 auto back() noexcept -> T& {
47 return _idx ? _values.front() : _values.back();
51 auto back() const noexcept -> const T& {
52 return _idx ? _values.front() : _values.back();
56 std::array<T, 2> _values{};
62 #endif // EAGINE_DOUBLE_BUFFER_HPP
Common code is placed in this namespace.
Definition: eagine.hpp:21
auto front() noexcept -> T &
Returns a reference to the current "front" instance.
Definition: double_buffer.hpp:36
void swap() noexcept
Swaps the front and the back buffers.
Definition: double_buffer.hpp:31
auto front() const noexcept -> const T &
Returns a const reference to the current "front" instance.
Definition: double_buffer.hpp:41
auto back() const noexcept -> const T &
Returns a const reference to the current "back" instance.
Definition: double_buffer.hpp:51
auto back() noexcept -> T &
Returns a reference to the current "back" instance.
Definition: double_buffer.hpp:46
Class holding two instances of type T and allows to switch them.
Definition: double_buffer.hpp:19
double_buffer(const T &initial)
Constructor setting the initial value for both buffers.
Definition: double_buffer.hpp:25
double_buffer()=default
Default constructor.