10#include "concepts.hpp"
12#include "../macros.hpp"
17hi_export_module(utility.not_null);
19hi_export
namespace hi {
inline namespace v1 {
21template<nullable_po
inter T>
25 using pointer = element_type *;
26 using reference = element_type &;
31 not_null &operator=(nullptr_t) =
delete;
35 template<nullable_po
inter O>
37 requires requires { this->_p = o._p; }
42 template<nullable_po
inter O>
44 requires requires { this->_p = o._p; }
46 if constexpr (std::same_as<std::remove_cvref_t<
decltype(*this)>, std::remove_cvref_t<
decltype(o)>>) {
56 template<nullable_po
inter O>
58 requires requires { this->_p =
std::move(o._p); }
63 template<nullable_po
inter O>
65 requires requires { this->_p =
std::move(o._p); }
67 if constexpr (std::same_as<std::remove_cvref_t<
decltype(*this)>, std::remove_cvref_t<
decltype(o)>>) {
77 template<nullable_po
inter O>
79 requires requires { this->_p = std::forward<O>(o); } :
80 _p(std::forward<O>(o))
82 hi_assert_not_null(_p);
85 template<nullable_po
inter O>
87 requires requires { this->_p = std::forward<O>(o); }
89 hi_assert_not_null(o);
90 _p = std::forward<O>(o);
100 operator T()
const noexcept
105 [[
nodiscard]] pointer get()
const noexcept
107 auto const r = [
this]{
108 if constexpr (std::is_pointer_v<T>) {
115 hi_assume(r !=
nullptr);
119 [[
deprecated(
"not_null<> pointers are always true")]]
explicit operator bool()
const noexcept
124 [[
deprecated(
"not_null<> pointers are never equal to nullptr")]] [[
nodiscard]]
bool operator==(nullptr_t)
const noexcept
129 [[
nodiscard]] reference operator*()
const noexcept
134 [[
nodiscard]] pointer operator->()
const noexcept
142 template<nullable_po
inter T>
146template<
typename T,
typename...
Args>
152template<
typename T,
typename...
Args>
Utilities to assert and bound check.
Utilities for throwing exceptions and terminating the application.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
Definition not_null.hpp:22