5#ifndef BITCOIN_UTIL_NOT_NULL_H
6#define BITCOIN_UTIL_NOT_NULL_H
43 requires std::is_class_v<T> &&
requires(
T t) { {
t !=
nullptr } -> std::convertible_to<bool>; }
47 template <std::convertible_to<T> U>
48 requires(!std::same_as<std::remove_cvref_t<U>,
NotNull>)
49 constexpr explicit NotNull(U&& u)
noexcept(std::is_nothrow_constructible_v<T, U&&>)
50 :
m_ptr(std::forward<U>(u))
56 requires std::move_constructible<U> && std::constructible_from<T, U&&>
57 constexpr explicit(!std::convertible_to<U, T>)
58 NotNull(
NotNull<U>&& other)
noexcept(std::is_nothrow_move_constructible_v<U> && std::is_nothrow_constructible_v<T, U&&>)
59 :
m_ptr(std::move(other).get())
65 requires std::convertible_to<const U&, T>
66 constexpr NotNull(
const NotNull<U>& other)
noexcept(std::is_nothrow_constructible_v<T, const U&>)
81 constexpr T get() &&
noexcept(std::is_nothrow_move_constructible_v<T>)
82 requires std::move_constructible<T>
90 constexpr operator T() const& noexcept(
std::is_nothrow_copy_constructible_v<T>)
91 requires
std::copy_constructible<T>
95 constexpr operator T() &&
noexcept(std::is_nothrow_move_constructible_v<T>)
96 requires std::move_constructible<T>
98 return std::move(*this).get();
104 return std::compare_three_way{}(
get(), other.
get());
109 return get() == other.
get();
119template <
typename T,
typename Deleter = std::default_delete<T>>
131 return std::hash<T>{}(v.get());
#define Assert(val)
Identity function.
#define Assume(val)
Assume is the identity function.
NotNull is intended to be used to denote that a smart pointer type can not hold a nullptr value.
constexpr auto operator<=>(const NotNull< U > &other) const
constexpr NotNull(U &&u) noexcept(std::is_nothrow_constructible_v< T, U && >)
constexpr NotNull(const NotNull &)=default
constexpr const T & get() const &noexcept LIFETIMEBOUND
constexpr NotNull(NotNull &&)=default
NotNull(std::nullptr_t)=delete
constexpr NotNull & operator=(NotNull &&)=default
constexpr bool operator==(const NotNull< U > &other) const
constexpr NotNull(const NotNull< U > &other) noexcept(std::is_nothrow_constructible_v< T, const U & >)
NotNull & operator=(std::nullptr_t)=delete
constexpr T get() &&noexcept(std::is_nothrow_move_constructible_v< T >)
constexpr NotNull & operator=(const NotNull &)=default
#define T(expected, seed, data)
NotNull(T) -> NotNull< T >
std::size_t operator()(const util::NotNull< T > &v) const noexcept