18#include <AUI/Traits/concepts.h>
19#include <AUI/Util/Assert.h>
34 unset_wrap()
noexcept:
40 unset_wrap(
const V& v);
46 const T& operator*()
const {
54 const T* operator->()
const {
58 T orDefault(
const T& def)
const {
65 template<
typename Destination>
66 void bindTo(Destination& destination)
const {
72 unset_wrap<T>& operator=(
const unset_wrap<T>& v)
noexcept;
74 template<aui::convertible_to<T> U>
75 unset_wrap<T>& operator=(
const unset_wrap<U>& v)
noexcept;
77 bool operator==(
const unset_wrap<T>& other)
const {
78 if (set != other.set) {
82 return stored == other.stored;
86 bool operator!=(
const unset_wrap<T>& other)
const {
87 return !(*
this == other);
90 void reset()
noexcept {
94 operator bool()
const {
101 namespace detail::unset {
102 template<
typename T, aui::convertible_to<T> U>
105 dst =
static_cast<T
>(*value);
109 template<
typename T, aui::convertible_to<T> U>
110 void init(unset_wrap<T>& wrap, T& dst,
bool& set, U&& value) {
111 dst =
static_cast<T
>(std::forward<U>(value));
119 unset_wrap<T>::unset_wrap(
const V& v)
121 detail::unset::init(*
this, stored, set, v);
126 detail::unset::init(*
this, stored, set, v);
131 template<aui::convertible_to<T> U>
133 detail::unset::init(*
this, stored, set, v);
139template <
typename T>
struct fmt::formatter<ass::unset_wrap<T>> {
140 template<
typename ParseContext>
141 constexpr auto parse(ParseContext& ctx)
148 return fmt::format_to(ctx.out(),
"{}", *c);
150 return fmt::format_to(ctx.out(),
"<unset>");
#define AUI_ASSERT(condition)
Asserts that the passed condition evaluates to true.
Definition Assert.h:55