13#if HX_USE_MACROS_WITH_MODULE
14#error Header does not provide macros alone.
22template<
typename T_>
class hxref;
27template<
typename>
struct hxis_hxref_ : hxfalse_t { };
28template<
typename U_>
struct hxis_hxref_<hxref<U_>> : hxtrue_t { };
61 template<
typename U_, hxenable_if_t<
62 !hxdetail_::hxis_hxref_<hxremove_cvref_t<U_>>
::value &&
63 !hxdetail_::hxis_hxoptional_<hxremove_cvref_t<U_>>
::value,
bool> =
true>
69 template<
typename U_, hxenable_if_t<
95 template<
typename U_, hxenable_if_t<
96 !hxdetail_::hxis_hxref_<hxremove_cvref_t<U_>>
::value &&
97 !hxdetail_::hxis_hxoptional_<hxremove_cvref_t<U_>>
::value,
bool> =
true>
113#if HX_CPLUSPLUS < 202002L
116 hxattr_nodiscard bool operator!=(const hxref& rhs_) const { return !(*this == rhs_); }
125 hxattr_nodiscard bool operator!=(
const T_& value_)
const {
return !(*
this == value_); }
133 template<
typename function_t_>
140 template<
typename U_>
150 template<
typename function_t_>
166 template<
typename U_=hxremove_cv_t<T_>>
181#include "detail/hxref.inl"
hxoptional<T> - Holds either a value of type T or nothing.
Definition hxoptional.hpp:52
hxref<T> - Holds a reference to a value of type T, or nothing.
Definition hxref.hpp:42
bool operator==(hxnullopt_t) const
Returns true if this reference is disengaged.
Definition hxref.hpp:107
bool operator==(const hxref &rhs_) const
Returns true if both references are disengaged or both reference equal values.
hxremove_cv_t< T > value_or(U_ &&default_value_) const
Returns the referenced value if engaged, otherwise returns default_value forwarded and converted to T...
hxref & operator=(U_ &value_)
Rebinds the reference to value.
T * operator->(void) const
Returns a pointer to the referenced value. The reference must be engaged.
hxref(const hxref< U_ > &other_)
Binds a reference by converting the referent of other.
T & value(void) const
Returns a reference to the referenced value. The reference must be engaged.
T & emplace(U_ &value_)
Binds the reference to value, engaging the reference.
void reset(void)
Disengages the reference. The referent is not affected.
Definition hxref.hpp:154
hxref(U_ &value_)
Binds a reference to value.
bool operator==(const T &value_) const
Returns true if this reference is engaged and its referent equals value.
hxref & operator=(hxnullopt_t)
Disengages the reference.
Definition hxref.hpp:91
auto 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 dise...
hxref(hxoptional< U_ > &other_)
Binds a reference by converting the value of other.
hxref(hxnullopt_t)
Constructs a disengaged hxref from hxnullopt.
Definition hxref.hpp:56
hxref or_else(function_t_ &&callable_) const
Returns a copy of this reference if engaged, otherwise returns the result of calling callable.
void swap(hxref &other_) noexcept
Exchanges the bound pointers with other.
hxref(void)
Constructs a disengaged hxref.
Definition hxref.hpp:52
T & value_type
value_type - Publishes the referenced value type.
Definition hxref.hpp:49
T & operator*(void) const
Returns a reference to the referenced value. The reference must be engaged.
bool has_value(void) const
Returns true if the reference is engaged.
Definition hxref.hpp:144
hxhash_t hxkey_hash(const hxref< T > &ref_)
hxkey_hash(hxref<T>) - Returns the hash of the referenced value if engaged, otherwise 1u.
Definition hxref.hpp:177
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:89
typename hxremove_cv_< T >::type hxremove_cv_t
Internal.
Definition hxutility.h:92
hxremove_cv_t< hxremove_reference_t< T > > hxremove_cvref_t
hxremove_cvref_t<T> - Returns T with const, volatile, and references removed.
Definition hxutility.h:115
T && hxdeclval(void) noexcept
hxdeclval - Implements std::declval.
Provides core macros, memory management and feature detection.
#define hxnull
hxnull - The null pointer value for a given pointer type represented by the numeric constant 0.
Definition libhatchet.h:277
uint32_t hxhash_t
hxhash_t - Unsigned 32-bit hash value. Expect collisions.
Definition libhatchet.h:212
static constexpr bool value
Definition hxutility.h:124
hxnullopt_t - A tag type used to construct a disengaged hxoptional.
Definition hxoptional.hpp:34