18#include <AUI/Traits/concepts.h>
19#include <AUI/Util/Assert.h>
39 unset_wrap(
const V& v);
48 const T& operator*()
const {
56 const T* operator->()
const {
60 T orDefault(
const T& def)
const {
67 template<
typename Destination>
68 void bindTo(Destination& destination)
const {
74 unset_wrap<T>& operator=(
const unset_wrap<T>& v)
noexcept;
76 template<aui::convertible_to<T> U>
77 unset_wrap<T>& operator=(
const unset_wrap<U>& v)
noexcept;
79 bool operator==(
const unset_wrap<T>& other)
const {
80 if (set != other.set) {
84 return stored == other.stored;
88 bool operator!=(
const unset_wrap<T>& other)
const {
89 return !(*
this == other);
92 void reset()
noexcept {
96 operator bool()
const {
103 namespace detail::unset {
104 template<
typename T, aui::convertible_to<T> U>
107 dst =
static_cast<T
>(*value);
111 template<
typename T, aui::convertible_to<T> U>
112 void init(unset_wrap<T>& wrap, T& dst,
bool& set, unset_wrap<U>&& value) {
114 dst =
static_cast<T&&
>(*value);
118 template<
typename T, aui::convertible_to<T> U>
119 void init(unset_wrap<T>& wrap, T& dst,
bool& set, U&& value) {
120 dst =
static_cast<T&&
>(value);
123 template<
typename T, aui::convertible_to<T> U>
124 void init(unset_wrap<T>& wrap, T& dst,
bool& set,
const U& value) {
125 dst =
static_cast<T
>(value);
133 unset_wrap<T>::unset_wrap(
const V& v)
135 detail::unset::init(*
this, stored, set, v);
141 unset_wrap<T>::unset_wrap(V&& v)
143 detail::unset::init(*
this, stored, set, std::forward<V>(v));
148 detail::unset::init(*
this, stored, set, v);
153 template<aui::convertible_to<T> U>
155 detail::unset::init(*
this, stored, set, v);
161template <
typename T>
struct fmt::formatter<ass::unset_wrap<T>> {
162 template<
typename ParseContext>
163 constexpr auto parse(ParseContext& ctx)
170 return fmt::format_to(ctx.out(),
"{}", *c);
172 return fmt::format_to(ctx.out(),
"<unset>");
#define AUI_ASSERT(condition)
Asserts that the passed condition evaluates to true.
Definition Assert.h:55