template <typename T>
muu::emplacement_array class

Simple std::vector-like array type for immovable or move-only types.

Template parameters
T Element type stored in the array.

Public types

using const_iterator = const_pointer
Const iterator to a member of the array.
using const_pointer = const value_type*
Const pointer to the array's value type.
using const_reference = const value_type&
Const reference to the array's value type.
using difference_type = ptrdiff_t
Signed index type.
using iterator = pointer
Iterator to a member of the array.
using pointer = value_type*
Pointer to the array's value type.
using reference = value_type&
Reference to the array's value type.
using size_type = size_t
Unsigned index type.
using value_type = T
The array's value type.

Constructors, destructors, conversion operators

emplacement_array(size_t capacity = 0) explicit
Constructor.
emplacement_array(emplacement_array&& other) noexcept
Move constructor.
~emplacement_array() noexcept
Destructor.

Public functions

auto back() -> reference noexcept
Returns the last element in the array.
auto back() const -> const_reference noexcept
Returns the last element in the array.
auto capacity() const -> size_type noexcept
The maximum number of elements that can be stored in the array.
void clear() noexcept(…)
Clears the array, destroying all currently allocated elements and resetting size to zero.
auto data() -> pointer noexcept
Returns a pointer to the first element in the array.
auto data() const -> const_pointer noexcept
Returns a const pointer to the first element in the array.
template <typename... Args>
auto emplace_back(Args && ... args) -> reference noexcept(…)
Constructs one new element at the end of the array.
template <typename EmplacementFunc, typename... ARGS>
auto emplace_back_with(EmplacementFunc&& func) -> reference noexcept(…)
Constructs one new element in the array using a construction functor for the emplacement.
auto empty() const -> bool noexcept
Returns true if the array is empty.
auto front() -> reference noexcept
Returns the first element in the array.
auto front() const -> const_reference noexcept
Returns the first element in the array.
auto operator=(emplacement_array&& rhs) -> emplacement_array& noexcept
Move-assignment operator.
auto operator[](size_t index) -> reference noexcept
Returns a reference to the element at the selected index.
auto operator[](size_t index) const -> const_reference noexcept
Returns a const reference to the element at the selected index.
auto size() const -> size_type noexcept
The number of elements in the array.

Iterators

auto begin() -> iterator noexcept
Returns an iterator to the first element in the array.
auto begin() const -> const_iterator noexcept
Returns a const_iterator to the first element in the array.
auto cbegin() const -> const_iterator noexcept
Returns a const_iterator to the first element in the array.
auto cend() const -> const_iterator noexcept
Returns a const_iterator to one-past-the-last element in the array.
auto end() -> iterator noexcept
Returns an iterator to one-past-the-last element in the array.
auto end() const -> const_iterator noexcept
Returns a const_iterator to one-past-the-last element in the array.

Iterators (ADL)

auto begin(emplacement_array& arr) -> iterator noexcept
Returns an iterator to the first element in the array.
auto begin(const emplacement_array& arr) -> const_iterator noexcept
Returns a const_iterator to the first element in the array.
auto cbegin(const emplacement_array& arr) -> const_iterator noexcept
Returns a const_iterator to the first element in the array.
auto cend(const emplacement_array& arr) -> const_iterator noexcept
Returns a const_iterator to one-past-the-last element in the array.
auto end(emplacement_array& arr) -> iterator noexcept
Returns an iterator to one-past-the-last element in the array.
auto end(const emplacement_array& arr) -> const_iterator noexcept
Returns a const_iterator to one-past-the-last element in the array.

Function documentation

template <typename T>
muu::emplacement_array::emplacement_array(size_t capacity = 0) explicit

Constructor.

Parameters
capacity The maximum number of elements the array needs to be able to store.

template <typename T>
template <typename... Args>
reference muu::emplacement_array::emplace_back(Args && ... args) noexcept(…)

Constructs one new element at the end of the array.

Template parameters
Args Constructor argument types.
Parameters
args Arguments to pass to the element's constructor.
Returns A reference to the newly-constructed element.

template <typename T>
template <typename EmplacementFunc, typename... ARGS>
reference muu::emplacement_array::emplace_back_with(EmplacementFunc&& func) noexcept(…)

Constructs one new element in the array using a construction functor for the emplacement.

Template parameters
EmplacementFunc A callable type with the signature T*(void*).
ARGS
Parameters
func A callable responsible for performing the placement-new construction.
Returns A reference to the newly-constructed element.