Skip to content

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.

Template parameters
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>()

constructor small_buffer<T, Capacity>(std::size_t)

small_buffer(std::size_t size)

Constructs a buffer with size default-initialized elements.

Parameters
size Number of elements to allocate.

Fully qualified name: kfr::small_buffer<T, Capacity>::small_buffer<T, Capacity>(std::size_t)

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> &)

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> &&)

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> &)

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.

Returns
Reference to *this.

Fully qualified name: kfr::small_buffer<T, Capacity>::operator=(small_buffer<T, Capacity>)

destructor ~small_buffer<T, Capacity>()

~small_buffer()

Destructor; releases any heap allocation.

Fully qualified name: kfr::small_buffer<T, Capacity>::~small_buffer<T, Capacity>()

function assign(const small_buffer<T, Capacity> &)

void assign(const small_buffer<T, Capacity>& other)

Replaces the contents with a copy of other.

Parameters
other Buffer to copy from.

Fully qualified name: kfr::small_buffer<T, Capacity>::assign(const small_buffer<T, Capacity> &)

function resize(std::size_t)

void resize(std::size_t newsize)

Resizes the buffer to newsize elements.

Parameters
newsize New number of elements.

Fully qualified name: kfr::small_buffer<T, Capacity>::resize(std::size_t)

function empty()

bool empty() const

Returns
true if the buffer contains no elements.

Fully qualified name: kfr::small_buffer<T, Capacity>::empty()

function size()

std::size_t size() const

Returns
Number of elements currently stored.

Fully qualified name: kfr::small_buffer<T, Capacity>::size()

function begin()

const T* begin() const

Returns
Const pointer to the first element.

Fully qualified name: kfr::small_buffer<T, Capacity>::begin()

function end()

const T* end() const

Returns
Const pointer one past the last element.

Fully qualified name: kfr::small_buffer<T, Capacity>::end()

function cbegin()

const T* cbegin() const

Returns
Const pointer to the first element.

Fully qualified name: kfr::small_buffer<T, Capacity>::cbegin()

function cend()

const T* cend() const

Returns
Const pointer one past the last element.

Fully qualified name: kfr::small_buffer<T, Capacity>::cend()

function begin()

T* begin()

Returns
Pointer to the first element.

Fully qualified name: kfr::small_buffer<T, Capacity>::begin()

function end()

T* end()

Returns
Pointer one past the last element.

Fully qualified name: kfr::small_buffer<T, Capacity>::end()

function clear()

void clear()

Resets the buffer to zero elements, releasing any heap allocation.

Fully qualified name: kfr::small_buffer<T, Capacity>::clear()

function front()

const T& front() const

Returns
Const reference to the first element.

Fully qualified name: kfr::small_buffer<T, Capacity>::front()

function back()

const T& back() const

Returns
Const reference to the last element.

Fully qualified name: kfr::small_buffer<T, Capacity>::back()

function front()

T& front()

Returns
Reference to the first element.

Fully qualified name: kfr::small_buffer<T, Capacity>::front()

function back()

T& back()

Returns
Reference to the last element.

Fully qualified name: kfr::small_buffer<T, Capacity>::back()

function pop_back()

void pop_back()

Removes the last element.

Fully qualified name: kfr::small_buffer<T, Capacity>::pop_back()

function data()

T* data()

Returns
Pointer to the underlying element storage.

Fully qualified name: kfr::small_buffer<T, Capacity>::data()

function data()

const T* data() const

Returns
Const pointer to the underlying element storage.

Fully qualified name: kfr::small_buffer<T, Capacity>::data()

function operator[](std::size_t)

T& operator[](std::size_t i)

Returns
Reference to the element at index i.

Fully qualified name: kfr::small_buffer<T, Capacity>::operator[](std::size_t)

function operator[](std::size_t)

const T& operator[](std::size_t i) const

Returns
Const reference to the element at index i.

Fully qualified name: kfr::small_buffer<T, Capacity>::operator[](std::size_t)

function push_back(const T &)

void push_back(const T& value)

Appends value to the end of the buffer.

Parameters
value Value to append.

Fully qualified name: kfr::small_buffer<T, Capacity>::push_back(const T &)

variable m_preallocated

T m_preallocated[Capacity]

Inline storage for up to

Capacity elements.

Fully qualified name: kfr::small_buffer<T, Capacity>::m_preallocated

variable m_size

std::size_t m_size

Number of elements currently stored.

Fully qualified name: kfr::small_buffer<T, Capacity>::m_size

variable m_data

T* m_data

Pointer to the active storage (inline or heap).

Fully qualified name: kfr::small_buffer<T, Capacity>::m_data

Fully qualified name: kfr::small_buffer<T, Capacity>

This file was generated by cxxdox, a C++ documentation generator based on MkDocs Material and libclang.