12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
29template<
typename T_,
typename deleter_t_=hxdefault_delete>
30class hxptr :
private deleter_t_ {
34 static_assert(!
hxis_array<T_>(),
"hxptr does not support array types");
81#if HX_CPLUSPLUS < 202002L
84 hxattr_nodiscard hxconstexpr bool operator!=(const hxptr& x_) const;
90#if HX_CPLUSPLUS >= 202302L
95 template<
typename self_t_,
typename callable_t_>
125#if HX_CPLUSPLUS >= 202302L
130 template<
typename self_t_,
typename callable_t_>
132 this self_t_&& self_, callable_t_&& callable_)
153#if HX_CPLUSPLUS >= 202302L
157 template<
typename self_t_,
typename... args_t_>
159 this self_t_&& self_, args_t_&&... args_);
186template<
typename T_,
typename deleter_t_>
197template<
typename T_,
typename deleter_t_>
206#include "detail/hxptr.inl"
hxdefault_delete - A callable that deletes objects of type T using hxdelete.
Definition hxmemory_manager.h:265
bool operator()(const hxptr< T, deleter_t_ > &x_, const hxptr< T, deleter_t_ > &y_) const
Definition hxptr.hpp:189
hxkey_equal_t<T> - A constexpr callable that returns true if two objects are equivalent.
Definition hxkey.hpp:57
hxhash_t operator()(const hxptr< T, deleter_t_ > &ptr_) const
Definition hxptr.hpp:201
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
hxptr<T, deleter_t> - A unique owning pointer.
Definition hxptr.hpp:30
constexpr hxremove_cv_t< T > value_or(this self_t_ &&self_, args_t_ &&... args_)
Returns the owned value if non-null, otherwise returns a T constructed from args.
constexpr hxptr(T *ptr_=0, deleter_t_ deleter_=deleter_t_()) noexcept
Constructs an hxptr that takes ownership of ptr with a specific deleter instance.
constexpr T * get(void) const
Returns the owned pointer without releasing ownership.
Definition hxptr.hpp:117
constexpr bool has_value(void) const
Returns true if the owned pointer is non-null.
Definition hxptr.hpp:123
constexpr T & operator*(void) const
Returns a reference to the owned object. The pointer must not be null.
constexpr hxptr or_else(this self_t_ &&self_, callable_t_ &&callable_)
Returns this hxptr moved out if non-null, otherwise returns the result of calling callable.
constexpr ~hxptr(void) noexcept
Destroys the owned object using deleter_t if non-null.
constexpr 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 owned object if non-null, otherwise returns hxnil.
constexpr T * release(void)
Releases ownership and returns the previously owned pointer without invoking the deleter.
constexpr void reset(T *ptr_=0) noexcept
Destroys the currently owned object using deleter_t if non-null, then takes ownership of ptr.
constexpr const deleter_t_ & deleter(void) const
Returns a const reference to the stored deleter.
constexpr hxptr(hxptr &&x_) noexcept
Move constructor.
constexpr void swap(hxptr &x_) noexcept
Exchanges ownership with x.
constexpr bool operator==(const hxptr &x_) const
Returns true if this and x point to the same object.
Definition hxptr.hpp:76
T element_t
Definition hxptr.hpp:39
T & emplace(args_t_ &&... args_) noexcept
Replaces the owned object with one constructed from args and returns a reference to it.
constexpr T & value(void) const
Returns a reference to the owned object without releasing ownership.
constexpr deleter_t_ & deleter(void)
constexpr bool equal(const hxptr &x_) const
Returns true if this and x point to the same object.
constexpr T * operator->(void) const
Returns the owned pointer. The pointer must not be null.
constexpr hxptr & operator=(hxptr &&x_) noexcept
Move assignment.
constexpr bool operator==(hxnil_t) const
Returns true if the owned pointer is null.
hxhash_t hash(void) const
Returns the hash of the owned value if non-null, otherwise 31u.
User-specializable key-equal, key-less, and key-hash callables.
@ hxsystem_allocator_current
hxsystem_allocator_current - Use current allocation scope.
Definition hxmemory_manager.h:80
HX_C_BEGIN_ typedef unsigned int hxalignment_t
hxalignment_t - A positive integer power of 2 for aligning allocations.
Definition hxmemory_manager.h:62
int hxsystem_allocator_t
hxsystem_allocator_t - This is extendable by the application.
Definition hxmemory_manager.h:75
hxattr_noexcept hxsystem_allocator_t allocator_
Definition hxmemory_manager.h:120
hxattr_noexcept hxsystem_allocator_t hxalignment_t alignment_
Definition hxmemory_manager.h:121
constexpr hxalignment_t hxalignment
hxalignment - The default alignment.
Definition hxmemory_manager.h:67
hxptr< T, deleter_t_ > hxmake_ptr(const U_ &value_) noexcept
hxmake_ptr<T, deleter, allocator, align>(value) - Allocates and constructs an object of type T from v...
Definition hxptr.hpp:181
#define hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:125
#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
#define hxconstexpr
hxconstexpr - Enables C++23 compatable constexpr usage for functions as that has support for destruct...
Definition hxsettings.h:266
typename hxremove_cv_< T >::type hxremove_cv_t
hxremove_cv_t - Removes const and volatile from a type.
Definition hxutility.h:79
constexpr bool hxis_rvalue_reference(void)
hxis_rvalue_reference<T> - Implements std::is_rvalue_reference.
Definition hxutility.h:237
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
constexpr bool hxis_array(void)
hxis_array<T> - Implements std::is_array.
Definition hxutility.h:148
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 hxis_pointer(void)
hxis_pointer<T> - Implements std::is_pointer.
Definition hxutility.h:216
constexpr bool hxis_const(void)
hxis_const<T> - Implements std::is_const.
Definition hxutility.h:157
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