11static_assert(
HX_CPLUSPLUS >= 202302L,
"hxref.hpp requires C++23");
14#if HX_USE_MACROS_WITH_MODULE
15#error Header does not provide macros alone.
23template<
typename T_>
class hxref;
27template<
typename>
struct hxis_hxref_ :
hxfalse_t { };
28template<
typename U_>
struct hxis_hxref_<
hxref<U_>> :
hxtrue_t { };
58 template<
typename U_, hxenable_if_t<
59 !hxis_hxref_<hxremove_cvref_t<U_>>
::value &&
60 !hxis_hxexpected_<hxremove_cvref_t<U_>>
::value &&
87 template<
typename U_, hxenable_if_t<
88 !hxis_hxref_<hxremove_cvref_t<U_>>
::value &&
89 !hxis_hxexpected_<hxremove_cvref_t<U_>>
::value &&
111 template<
typename self_t_,
typename callable_t_>
130 template<
typename self_t_,
typename callable_t_>
147 template<
typename self_t_,
typename... args_t_>
149 this self_t_&& self_, args_t_&&... args_);
158template<typename T_, typename U_=T_, hxenable_if_t<hxbinds_directly<T_, U_>(),
bool> =
true>
183#include "detail/hxref.inl"
hxexpected<T, E=bool> - Holds either a value of type T or an error of type E.
Definition hxexpected.hpp:67
bool operator()(const hxref< T > &x_, const hxref< T > &y_) const
Definition hxref.hpp:166
hxkey_equal_t<T> - A constexpr callable that returns true if two objects are equivalent.
Definition hxkey.hpp:57
hxhash_t operator()(const hxref< T > &ref_) const
Definition hxref.hpp:178
hxkey_hash_t<T> - A callable that returns the xxhash32 of a numeric value cast to 32 bits.
Definition hxkey.hpp:146
hxnil_t - A class that will only convert to a null T pointer or a null hxhandle_t.
Definition hxutility.h:57
hxref<T> - Holds a reference to a value of type T, or null.
Definition hxref.hpp:39
hxref(hxnil_t)
Constructs a null hxref from hxnil.
Definition hxref.hpp:53
bool operator==(hxnil_t) const
Returns true if this reference is null.
Definition hxref.hpp:100
hxref & operator=(U_ &value_)
Rebinds the reference to value.
T * operator->(void) const
Returns a pointer to the referenced value.
hxref(hxexpected< T, E_ > &x_)
Binds a reference to the value of x.
bool operator==(const hxref &x_) const
Returns true if both references are null or both reference equal values.
Definition hxref.hpp:96
T & value(void) const
Returns a reference to the referenced value.
hxref or_else(this self_t_ &&self_, callable_t_ &&callable_)
Returns a copy of this reference if non-null, otherwise returns the result of calling callable.
void reset(void)
Nulls the reference. The referent is not affected.
Definition hxref.hpp:134
bool equal(const hxref &x_) const
Returns true if both references are null or both reference equal values.
hxremove_cv_t< T > value_or(this self_t_ &&self_, args_t_ &&... args_)
Returns the referenced value if non-null, otherwise returns a T constructed from args.
hxref(U_ &value_)
Binds a reference to value.
void swap(hxref &x_) noexcept
Exchanges the bound pointers with x.
bool operator==(const T &value_) const
Returns true if this reference is non-null and its referent equals value.
T & value_t
value_type - Publishes the referenced value type.
Definition hxref.hpp:46
hxref & operator=(hxnil_t)
Nulls the reference.
Definition hxref.hpp:83
hxref(void)
Constructs a null hxref.
Definition hxref.hpp:49
hxhash_t hash(void) const
Returns the hash of the referenced value if non-null, otherwise 31u.
T & operator*(void) const
Returns a reference to the referenced value.
auto and_then(this self_t_ &&self_, callable_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxdeclval< T & >()))>
Returns the result of calling callable with the referenced value if non-null, otherwise returns hxnil...
bool has_value(void) const
Returns true if the reference is non-null.
Definition hxref.hpp:121
hxref< T > hxmake_ref(U_ &value_)
hxmake_ref<T> - Returns an hxref<T> bound to value.
Definition hxref.hpp:159
#define hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:125
#define HX_CPLUSPLUS
HX_CPLUSPLUS - A version of __cplusplus that is defined to 0 when __cplusplus is undefined.
Definition hxsettings.h:31
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:98
#define hxattr_flatten
hxattr_flatten - Inline every call inside a function's body into it, recursively, regardless of the c...
Definition hxsettings.h:90
typename hxremove_cv_< T >::type hxremove_cv_t
hxremove_cv_t - Removes const and volatile from a type.
Definition hxutility.h:79
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:103
T && hxdeclval(void) noexcept
hxdeclval - Implements std::declval.
constexpr bool hxis_reference(void)
hxis_reference<T> - Implements std::is_reference.
Definition hxutility.h:228
constexpr bool hxbinds_directly(void)
hxbinds_directly<T, U> - Returns true when an lvalue of type U binds to T& without creating a tempora...
Definition hxutility.h:138
Provides core macros, memory management and feature detection.
#define hxnull
hxnull - The null pointer value for a given pointer type represented by the numeric literal 0.
Definition libhatchet.h:280
uint32_t hxhash_t
hxhash_t - Unsigned 32-bit hash value. Expect collisions.
Definition libhatchet.h:210
hxfalse_t - Implements std::false_type.
Definition hxutility.h:112
hxtrue_t - Implements std::true_type.
Definition hxutility.h:110