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_ {
77#if HX_CPLUSPLUS < 202002L
80 hxattr_nodiscard hxconstexpr bool operator!=(const hxptr& other_) const;
90 template<
typename function_t_>
107 template<
typename function_t_>
111 template<
typename function_t_>
130 template<
typename U_=hxremove_cv_t<T_>>
153#include "detail/hxptr.inl"
hxnullptr_t - A class that will only convert to a null T pointer.
Definition hxutility.h:64
hxptr<T, deleter_t> - A unique owning pointer.
Definition hxptr.hpp:30
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:101
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 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 owned object if non-null, otherwise returns a null hx...
constexpr hxptr or_else(function_t_ &&callable_) &&
Returns this hxptr moved out if non-null, otherwise returns the result of calling callable.
T element_t
Definition hxptr.hpp:39
constexpr deleter_t_ & deleter(void)
Returns a reference to the stored deleter.
constexpr hxptr & operator=(hxptr &&other_) noexcept
Move assignment.
hxptr or_else(function_t_ &&callable_) const &=delete
constexpr void swap(hxptr &other_) noexcept
Exchanges ownership with other.
constexpr hxremove_cv_t< T > value_or(U_ &&default_value_) const
Returns the owned value if non-null, otherwise returns default_value forwarded and converted to T.
@ hxsystem_allocator_current
hxsystem_allocator_current - Use current allocation scope.
Definition hxmemory_manager.h:82
int hxsystem_allocator_t
hxsystem_allocator_t - This is extendable by the application.
Definition hxmemory_manager.h:77
unsigned int hxalignment_t
hxalignment_t - A positive integer power of 2 for aligning allocations.
Definition hxmemory_manager.h:64
T * hxnew(Args_ &&... args_) noexcept
hxnew<T, allocator, align>(...) - Allocates and constructs an object of type T using an optional memo...
Definition hxmemory_manager.h:235
constexpr hxalignment_t hxalignment
hxalignment - The default alignment.
Definition hxmemory_manager.h:69
hxptr< T > hxmake_ptr(args_t_ &&... args_) noexcept
hxmake_ptr<T, allocator, align>(args...) - Allocates and constructs an object of type T and returns i...
Definition hxptr.hpp:149
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:89
#define hxconstexpr
hxconstexpr - Enables C++23 compatable constexpr usage for functions as that has support for destruct...
Definition hxsettings.h:263
A few utility functions and most standard C++ meta programming functions.
typename hxremove_cv_< T >::type hxremove_cv_t
Internal.
Definition hxutility.h:92
constexpr T && hxforward(hxremove_reference_t< T > &&x_)
hxforward - Implements std::forward.
Definition hxutility.h:304
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
static constexpr bool value
Definition hxutility.h:124
hxis_pointer - Returns whether T is a pointer type as hxis_pointer<T>::value.
Definition hxutility.h:206