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>
82 hi_assert_not_null(_p);
85 template<nullable_po
inter O>
89 hi_assert_not_null(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>
171[[nodiscard]]
not_null<T *> make_not_null(T &&ptr)
noexcept =
delete;
Utilities to assert and bound check.
Utilities for throwing exceptions and terminating the application.
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
The HikoGUI API version 1.
Definition recursive_iterator.hpp:16
constexpr matrix2 operator*(matrix2 const &lhs, matrix2 const &rhs) noexcept
Matrix/Matrix multiplication.
Definition transform.hpp:69
Definition not_null.hpp:22