#include <muu/emplacement_array.h>
template <typename T>
emplacement_array class
Simple std::
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(…)
template <typename... Args>
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(…)
template <typename EmplacementFunc, typename... ARGS>
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. |