Class small_buffer¶
class small_buffer<T, Capacity> base¶
template <typename T, std::size_t Capacity = 16>
struct small_buffer { … } A dynamically-sized buffer with a small-size optimization.
| T | Element type. |
| Capacity | Number of elements kept in the inline (preallocated) storage. |
constructor small_buffer<T, Capacity>() ¶
small_buffer() noexcept Constructs an empty buffer pointing at the inline storage.
Fully qualified name: kfr::small_buffer<T, Capacity>::small_buffer<T, Capacity>()
Declared at base/small_buffer.hpp:47
constructor small_buffer<T, Capacity>(std::size_t) ¶
small_buffer(std::size_t size) Constructs a buffer with size default-initialized elements.
| size | Number of elements to allocate. |
Fully qualified name: kfr::small_buffer<T, Capacity>::small_buffer<T, Capacity>(std::size_t)
Declared at base/small_buffer.hpp:53
function swap(small_buffer<T, Capacity> &, small_buffer<T, Capacity> &) ¶
friend void swap(small_buffer<T, Capacity>& first, small_buffer<T, Capacity>& second) noexcept Swaps the contents of two buffers.
After the swap each buffer correctly points either at its own inline storage or at its heap allocation depending on the resulting size.
Fully qualified name: kfr::small_buffer<T, Capacity>::swap(small_buffer<T, Capacity> &, small_buffer<T, Capacity> &)
Declared at base/small_buffer.hpp:61
constructor small_buffer<T, Capacity>(small_buffer<T, Capacity> &&) ¶
small_buffer(small_buffer<T, Capacity>&& other) Move-constructs from other, leaving other in an empty state.
Fully qualified name: kfr::small_buffer<T, Capacity>::small_buffer<T, Capacity>(small_buffer<T, Capacity> &&)
Declared at base/small_buffer.hpp:72
constructor small_buffer<T, Capacity>(const small_buffer<T, Capacity> &) ¶
small_buffer(const small_buffer<T, Capacity>& other) Copy-constructs from other.
Fully qualified name: kfr::small_buffer<T, Capacity>::small_buffer<T, Capacity>(const small_buffer<T, Capacity> &)
Declared at base/small_buffer.hpp:75
function operator=(small_buffer<T, Capacity>) ¶
small_buffer<T, Capacity>& operator=(small_buffer<T, Capacity> other) Copy- and move-assigns from other using copy-and-swap.
Reference to *this. |
Fully qualified name: kfr::small_buffer<T, Capacity>::operator=(small_buffer<T, Capacity>)
Declared at base/small_buffer.hpp:80
destructor ~small_buffer<T, Capacity>() ¶
~small_buffer() Destructor; releases any heap allocation.
Fully qualified name: kfr::small_buffer<T, Capacity>::~small_buffer<T, Capacity>()
Declared at base/small_buffer.hpp:87
function assign(const small_buffer<T, Capacity> &) ¶
void assign(const small_buffer<T, Capacity>& other) Replaces the contents with a copy of other.
| other | Buffer to copy from. |
Fully qualified name: kfr::small_buffer<T, Capacity>::assign(const small_buffer<T, Capacity> &)
Declared at base/small_buffer.hpp:93
function resize(std::size_t) ¶
void resize(std::size_t newsize) Resizes the buffer to newsize elements.
| newsize | New number of elements. |
Fully qualified name: kfr::small_buffer<T, Capacity>::resize(std::size_t)
Declared at base/small_buffer.hpp:108
function empty() ¶
bool empty() const
true if the buffer contains no elements. |
Fully qualified name: kfr::small_buffer<T, Capacity>::empty()
Declared at base/small_buffer.hpp:129
function size() ¶
std::size_t size() const
| Number of elements currently stored. |
Fully qualified name: kfr::small_buffer<T, Capacity>::size()
Declared at base/small_buffer.hpp:131
function begin() ¶
const T* begin() const
| Const pointer to the first element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::begin()
Declared at base/small_buffer.hpp:133
function end() ¶
const T* end() const
| Const pointer one past the last element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::end()
Declared at base/small_buffer.hpp:135
function cbegin() ¶
const T* cbegin() const
| Const pointer to the first element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::cbegin()
Declared at base/small_buffer.hpp:137
function cend() ¶
const T* cend() const
| Const pointer one past the last element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::cend()
Declared at base/small_buffer.hpp:139
function begin() ¶
T* begin()
| Pointer to the first element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::begin()
Declared at base/small_buffer.hpp:141
function end() ¶
T* end()
| Pointer one past the last element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::end()
Declared at base/small_buffer.hpp:143
function clear() ¶
void clear() Resets the buffer to zero elements, releasing any heap allocation.
Fully qualified name: kfr::small_buffer<T, Capacity>::clear()
Declared at base/small_buffer.hpp:145
function front() ¶
const T& front() const
| Const reference to the first element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::front()
Declared at base/small_buffer.hpp:147
function back() ¶
const T& back() const
| Const reference to the last element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::back()
Declared at base/small_buffer.hpp:149
function front() ¶
T& front()
| Reference to the first element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::front()
Declared at base/small_buffer.hpp:151
function back() ¶
T& back()
| Reference to the last element. |
Fully qualified name: kfr::small_buffer<T, Capacity>::back()
Declared at base/small_buffer.hpp:153
function pop_back() ¶
void pop_back() Removes the last element.
Fully qualified name: kfr::small_buffer<T, Capacity>::pop_back()
Declared at base/small_buffer.hpp:155
function data() ¶
T* data()
| Pointer to the underlying element storage. |
Fully qualified name: kfr::small_buffer<T, Capacity>::data()
Declared at base/small_buffer.hpp:157
function data() ¶
const T* data() const
| Const pointer to the underlying element storage. |
Fully qualified name: kfr::small_buffer<T, Capacity>::data()
Declared at base/small_buffer.hpp:159
function operator[](std::size_t) ¶
T& operator[](std::size_t i)
Reference to the element at index i. |
Fully qualified name: kfr::small_buffer<T, Capacity>::operator[](std::size_t)
Declared at base/small_buffer.hpp:161
function operator[](std::size_t) ¶
const T& operator[](std::size_t i) const
Const reference to the element at index i. |
Fully qualified name: kfr::small_buffer<T, Capacity>::operator[](std::size_t)
Declared at base/small_buffer.hpp:163
function push_back(const T &) ¶
void push_back(const T& value) Appends value to the end of the buffer.
| value | Value to append. |
Fully qualified name: kfr::small_buffer<T, Capacity>::push_back(const T &)
Declared at base/small_buffer.hpp:168
variable m_preallocated ¶
T m_preallocated[Capacity] Inline storage for up to
Capacity elements.
Fully qualified name: kfr::small_buffer<T, Capacity>::m_preallocated
Declared at base/small_buffer.hpp:175
variable m_size ¶
std::size_t m_size Number of elements currently stored.
Fully qualified name: kfr::small_buffer<T, Capacity>::m_size
Declared at base/small_buffer.hpp:176
variable m_data ¶
T* m_data Pointer to the active storage (inline or heap).
Fully qualified name: kfr::small_buffer<T, Capacity>::m_data
Declared at base/small_buffer.hpp:177
Fully qualified name: kfr::small_buffer<T, Capacity>
Declared at base/small_buffer.hpp:43