|
libhatchet
|
#include <hxref.hpp>
Public Types | |
| using | value_type = T& |
Public Member Functions | |
| hxref (void) | |
| hxref (hxnullopt_t) | |
| template<typename U_, hxenable_if_t< !hxdetail_::hxis_hxref_< hxremove_cvref_t< U_ > >::value &&!hxdetail_::hxis_hxoptional_< hxremove_cvref_t< U_ > >::value, bool > = true> | |
| hxref (U_ &value_) | |
| template<typename U_, hxenable_if_t< !hxis_same< U_, T >::value, bool > = true> | |
| hxref (const hxref< U_ > &other_) | |
| template<typename U_> | |
| hxref (hxoptional< U_ > &other_) | |
| T & | operator* (void) const |
| T * | operator-> (void) const |
| operator bool (void) const | |
| hxref & | operator= (hxnullopt_t) |
| template<typename U_, hxenable_if_t< !hxdetail_::hxis_hxref_< hxremove_cvref_t< U_ > >::value &&!hxdetail_::hxis_hxoptional_< hxremove_cvref_t< U_ > >::value, bool > = true> | |
| hxref & | operator= (U_ &value_) |
| bool | operator== (const hxref &rhs_) const |
| bool | operator== (hxnullopt_t) const |
| bool | operator== (const T &value_) const |
| template<typename function_t_> | |
| auto | and_then (function_t_ &&callable_) const -> hxremove_cvref_t< decltype(hxforward< function_t_ >(callable_)(hxdeclval< T & >()))> |
| template<typename U_> | |
| T & | emplace (U_ &value_) |
| bool | has_value (void) const |
| template<typename function_t_> | |
| hxref | or_else (function_t_ &&callable_) const |
| void | reset (void) |
| void | swap (hxref &other_) noexcept |
| T & | value (void) const |
| template<typename U_ = hxremove_cv_t<T>> | |
| hxremove_cv_t< T > | value_or (U_ &&default_value_) const |
hxref<T> - Holds a reference to a value of type T, or nothing.
Implements std::optional<T&>. The reference is stored as a T* without dynamic allocation. A disengaged reference compares equal to hxnullopt. Assignment rebinds the reference instead of assigning through to the referent, so the post condition is independent of the engaged state. Const is shallow, matching the rebinding behavior. Use hxref<const T> where write through should be prevented. This is weird but so is the standard.
| using hxref< T >::value_type = T& |
value_type - Publishes the referenced value type.
Doesn't end with _t because of the standard.
|
inline |
| hxref< T >::hxref | ( | U_ & | value_ | ) |
Binds a reference by converting the referent of other.
The referent of other must bind to T& without creating a temporary.
Binds a reference by converting the value of other.
The referent of other must bind to T& without creating a temporary. Accepts an engaged or disengaged hxoptional<U>.
| auto hxref< T >::and_then | ( | function_t_ && | callable_ | ) | const->hxremove_cvref_t< decltype(hxforward< function_t_ >(callable_)(hxdeclval< T & >()))> |
Returns the result of calling callable with the referenced value if engaged, otherwise returns a disengaged optional of the same type.
callable must return an hxoptional. Implements std::optional::and_then.
|
inline |
Returns true if the reference is engaged.
|
inline |
Returns true if the reference is engaged.
| T & hxref< T >::operator* | ( | void | ) | const |
Returns a reference to the referenced value. The reference must be engaged.
| T * hxref< T >::operator-> | ( | void | ) | const |
Returns a pointer to the referenced value. The reference must be engaged.
|
inline |
Disengages the reference.
The referent is not affected.
| hxref & hxref< T >::operator= | ( | U_ & | value_ | ) |
Returns true if both references are disengaged or both reference equal values.
| bool hxref< T >::operator== | ( | const T & | value_ | ) | const |
|
inline |
Returns true if this reference is disengaged.
| hxref hxref< T >::or_else | ( | function_t_ && | callable_ | ) | const |
Returns a copy of this reference if engaged, otherwise returns the result of calling callable.
callable must return an hxref<T>. Implements std::optional::or_else.
|
inline |
Disengages the reference. The referent is not affected.
Exchanges the bound pointers with other.
| T & hxref< T >::value | ( | void | ) | const |
Returns a reference to the referenced value. The reference must be engaged.
| hxremove_cv_t< T > hxref< T >::value_or | ( | U_ && | default_value_ | ) | const |
Returns the referenced value if engaged, otherwise returns default_value forwarded and converted to T.