|
|
constexpr | annex () noexcept(std::is_nothrow_default_constructible_v< allocator_type >)=default |
| | Constructs an empty annex.
|
| |
|
constexpr | annex (std::nullopt_t) noexcept(std::is_nothrow_default_constructible_v< allocator_type >) |
| | Constructs an empty annex from std::nullopt.
|
| |
| | annex (allocator_type const &alloc) noexcept |
| | Constructs an empty annex using the specified allocator.
|
| |
| | annex (std::allocator_arg_t, allocator_type const &alloc) noexcept |
| | Constructs an empty annex using allocator-argument syntax.
|
| |
| | annex (annex const &other) |
| | Copy-constructs an annex.
|
| |
| | annex (annex &&other) noexcept(std::is_nothrow_move_constructible_v< allocator_type >) |
| | Move-constructs an annex by transferring its backing pointer.
|
| |
| template<typename U = T, typename = std::enable_if_t< std::is_constructible_v< T, U&& > && !std::is_same_v< std::decay_t< U >, annex > && !std::is_same_v< std::decay_t< U >, std::in_place_t > && !std::is_same_v< std::decay_t< U >, std::nullopt_t > && !std::is_same_v< std::decay_t< U >, allocator_type > >> |
| | annex (U &&value) |
| | Constructs an annex containing a value.
|
| |
| template<typename... Args> |
| | annex (std::in_place_t, Args &&... args) |
| | Constructs the contained value in place.
|
| |
| template<typename U, typename... Args> |
| | annex (std::in_place_t, std::initializer_list< U > init, Args &&... args) |
| | Constructs the contained value in place with an initializer list.
|
| |
| template<typename... Args> |
| | annex (std::allocator_arg_t, allocator_type const &alloc, std::in_place_t, Args &&... args) |
| | Constructs the contained value in place using the specified allocator.
|
| |
| template<typename U, typename... Args> |
| | annex (std::allocator_arg_t, allocator_type const &alloc, std::in_place_t, std::initializer_list< U > init, Args &&... args) |
| | Constructs the contained value in place with an initializer list and allocator.
|
| |
|
| ~annex () |
| | Destroys the contained value, if any, and releases its storage.
|
| |
| annex & | operator= (std::nullopt_t) noexcept |
| | Assigns the empty state.
|
| |
| annex & | operator= (annex const &other) |
| | Copy-assigns another annex.
|
| |
| annex & | operator= (annex &&other) noexcept(alloc_traits::propagate_on_container_move_assignment::value &&std::is_nothrow_move_assignable_v< allocator_type >) |
| | Move-assigns another annex.
|
| |
| template<typename U = T, typename = std::enable_if_t< std::is_constructible_v< T, U&& > && std::is_assignable_v< T&, U&& > && !std::is_same_v< std::decay_t< U >, annex > && !std::is_same_v< std::decay_t< U >, std::nullopt_t > >> |
| annex & | operator= (U &&value) |
| | Assigns a value to the annex.
|
| |
| constexpr T const * | operator-> () const noexcept |
| | Returns a pointer to the contained value.
|
| |
| constexpr T * | operator-> () noexcept |
| | Returns a pointer to the contained value.
|
| |
| constexpr T const & | operator* () const &noexcept |
| | Returns a const lvalue reference to the contained value.
|
| |
| constexpr T & | operator* () &noexcept |
| | Returns an lvalue reference to the contained value.
|
| |
| constexpr T const && | operator* () const &&noexcept |
| | Returns a const rvalue reference to the contained value.
|
| |
| constexpr T && | operator* () &&noexcept |
| | Returns an rvalue reference to the contained value.
|
| |
| constexpr | operator bool () const noexcept |
| | Tests whether the annex contains a value.
|
| |
| constexpr bool | has_value () const noexcept |
| | Tests whether the annex contains a value.
|
| |
| T & | value () & |
| | Returns the contained value.
|
| |
| T const & | value () const & |
| | Returns the contained value.
|
| |
| T && | value () && |
| | Returns the contained value as an rvalue reference.
|
| |
| T const && | value () const && |
| | Returns the contained value as a const rvalue reference.
|
| |
| template<typename U> |
| constexpr T | value_or (U &&default_value) const & |
| | Returns the contained value or a fallback.
|
| |
| template<typename U> |
| constexpr T | value_or (U &&default_value) && |
| | Returns the contained value or a fallback.
|
| |
| void | swap (annex &other) noexcept(alloc_traits::propagate_on_container_swap::value &&std::is_nothrow_swappable_v< allocator_type > &&std::is_nothrow_swappable_v< T >) |
| | Swaps this annex with another annex.
|
| |
|
void | reset () noexcept |
| | Destroys the contained value and makes the annex empty.
|
| |
| template<typename... Args> |
| T & | emplace (Args &&... args) |
| | Replaces the contained value by constructing a new value in place.
|
| |
| template<typename U, typename... Args> |
| T & | emplace (std::initializer_list< U > init, Args &&... args) |
| | Replaces the contained value using an initializer list.
|
| |
| allocator_type | get_allocator () const |
| | Returns a copy of the allocator.
|
| |
template<typename T, typename Alloc = std::allocator< T >>
class rpnx::annex< T, Alloc >
Optional-like value container that stores its payload out of line.
annex provides an API modeled after std::optional, but it stores the contained object through allocator-owned dynamic storage. Empty annex objects therefore only contain a pointer and allocator state, which is useful when T is large and the empty state is common.
Move construction and move assignment transfer the backing pointer when allocator rules allow it. This intentionally leaves the moved-from annex empty instead of engaged with a moved-from T.
- Template Parameters
-
| T | The type of value stored by the annex. |
| Alloc | Allocator used for the contained T. |