|
libhatchet
|
#include <hxoptional.hpp>
Public Types | |
| using | value_type = T |
Public Member Functions | |
| hxoptional (void) | |
| hxoptional (hxnullopt_t) | |
| hxoptional (const hxoptional &other_) noexcept | |
| hxoptional (hxoptional &&other_) noexcept | |
| template<typename U_> | |
| hxoptional (const hxoptional< U_ > &other_) noexcept | |
| template<typename U_> | |
| hxoptional (hxoptional< U_ > &&other_) noexcept | |
| template<typename U_ = T, hxenable_if_t< !hxdetail_::hxis_hxoptional_< hxremove_cvref_t< U_ > >::value, bool > = true> | |
| hxoptional (U_ &&value_) noexcept | |
| ~hxoptional (void) | |
| T & | operator* (void) |
| const T & | operator* (void) const |
| T * | operator-> (void) |
| const T * | operator-> (void) const |
| operator bool (void) const | |
| hxoptional & | operator= (const hxoptional &other_) noexcept |
| hxoptional & | operator= (hxoptional &&other_) noexcept |
| hxoptional & | operator= (hxnullopt_t) |
| template<typename U_ = T, hxenable_if_t< !hxdetail_::hxis_hxoptional_< hxremove_cvref_t< U_ > >::value, bool > = true> | |
| hxoptional & | operator= (U_ &&value_) noexcept |
| template<typename U_> | |
| hxoptional & | operator= (const hxoptional< U_ > &other_) noexcept |
| template<typename U_> | |
| hxoptional & | operator= (hxoptional< U_ > &&other_) noexcept |
| bool | operator== (const hxoptional &rhs_) const |
| bool | operator== (hxnullopt_t) const |
| bool | operator== (const T &value_) const |
| template<typename function_t_> | |
| auto | and_then (function_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< function_t_ >(callable_)(hxdeclval< T & >()))> |
| template<typename function_t_> | |
| auto | and_then (function_t_ &&callable_) const -> hxremove_cvref_t< decltype(hxforward< function_t_ >(callable_)(hxdeclval< const T & >()))> |
| template<typename... args_t_> | |
| T & | emplace (args_t_ &&... args_) noexcept |
| bool | has_value (void) const |
| template<typename function_t_> | |
| hxoptional | or_else (function_t_ &&callable_) const |
| void | reset (void) noexcept |
| void | swap (hxoptional &other_) noexcept |
| T & | value (void) |
| const T & | value (void) const |
| template<typename U_ = T> | |
| T | value_or (U_ &&default_value_) const |
hxoptional<T> - Holds either a value of type T or nothing.
Implements std::optional. See hxref for a std::optional<T&> equivalent. The value is stored in aligned internal storage without dynamic allocation. A disengaged optional compares equal to hxnullopt.
| using hxoptional< T >::value_type = T |
value_type - Publishes the contained value type.
Doesn't end with _t because of the standard.
|
inline |
Constructs a disengaged hxoptional.
|
inline |
Constructs a disengaged hxoptional from hxnullopt.
|
noexcept |
Copy constructor.
Copies the engaged state and value from other.
|
noexcept |
Move constructor.
Moves the engaged state and value from other. other is left disengaged.
|
noexcept |
Constructs by copying the engaged state and converting the value of other to T.
U must be convertible to T.
|
noexcept |
Constructs by moving the engaged state and converting the value of other to T.
other is left disengaged. U must be convertible to T.
|
noexcept |
Constructs an engaged hxoptional by forwarding value into storage.
|
inline |
Destroys the contained value if engaged.
| auto hxoptional< T >::and_then | ( | function_t_ && | callable_ | ) | ->hxremove_cvref_t< decltype(hxforward< function_t_ >(callable_)(hxdeclval< T & >()))> |
Returns the result of calling callable with the contained value if engaged, otherwise returns a disengaged optional of the same type.
callable must return an hxoptional.
| auto hxoptional< T >::and_then | ( | function_t_ && | callable_ | ) | const->hxremove_cvref_t< decltype(hxforward< function_t_ >(callable_)(hxdeclval< constT & >()))> |
Returns the result of calling callable with the contained value if engaged, otherwise returns a disengaged optional of the same type.
callable must return an hxoptional.
|
noexcept |
Constructs the contained value in place from args, destroying any previous value.
|
inline |
Returns true if the optional contains a value.
|
inline |
Returns true if the optional contains a value.
| T & hxoptional< T >::operator* | ( | void | ) |
Returns a reference to the contained value.
The optional must be engaged.
| const T & hxoptional< T >::operator* | ( | void | ) | const |
Returns a const reference to the contained value.
The optional must be engaged.
| T * hxoptional< T >::operator-> | ( | void | ) |
Returns a pointer to the contained value. The optional must be engaged.
| const T * hxoptional< T >::operator-> | ( | void | ) | const |
Returns a const pointer to the contained value.
The optional must be engaged.
|
noexcept |
Copy assignment.
Copies the engaged state and value from other.
|
noexcept |
Copies the engaged state and converts the value of other to T.
U must be convertible to T.
|
inline |
Disengages the optional, destroying any contained value.
|
noexcept |
Move assignment.
Moves the engaged state and value from other. other is left disengaged.
|
noexcept |
Moves the engaged state and converts the value of other to T.
other is left disengaged. U must be convertible to T.
|
noexcept |
| bool hxoptional< T >::operator== | ( | const hxoptional< T > & | rhs_ | ) | const |
Returns true if both optionals are disengaged or both are engaged with equal values.
| bool hxoptional< T >::operator== | ( | const T & | value_ | ) | const |
|
inline |
Returns true if this optional is disengaged.
| hxoptional hxoptional< T >::or_else | ( | function_t_ && | callable_ | ) | const |
Returns a copy of this optional if engaged, otherwise returns the result of calling callable.
callable must return an hxoptional<T>.
|
noexcept |
Destroys the contained value if engaged and leaves the optional disengaged.
|
noexcept |
Exchanges the contents with other.
Both engaged states and values are swapped.
| T & hxoptional< T >::value | ( | void | ) |
Returns a reference to the contained value.
The optional must be engaged.
| const T & hxoptional< T >::value | ( | void | ) | const |
Returns a const reference to the contained value.
The optional must be engaged.
| T hxoptional< T >::value_or | ( | U_ && | default_value_ | ) | const |
Returns the contained value if engaged, otherwise returns default_value forwarded and converted to T.