6#ifndef OPTIONALGADGET_H
7#define OPTIONALGADGET_H
9#ifdef STD_OPTIONAL_AVAILABLE
13#ifdef __cpp_lib_optional
17using optional = std::optional<T>;
23#define OPTIONAL_GADGET(T, name) \
30 class KCGROUPS_EXPORT name : public KCGroups::optional<T> \
39 Q_PROPERTY(T value READ getValue WRITE setValue RESET reset) \
45 Q_PROPERTY(bool hasValue READ hasValue) \
51 using value_type = T; \
53 using KCGroups::optional<T>::optional; \
61 return *this ? **this : T(); \
68 void setValue(const T &val) \
70 *reinterpret_cast<KCGroups::optional<T> *>(this) = val; \
79 return static_cast<bool>(*this); \
83 inline bool operator==(const name &lhs, const name &rhs) \
85 return static_cast<KCGroups::optional<typename name::value_type>>(lhs) == \
86 static_cast<KCGroups::optional<typename name::value_type>>(rhs); \
89 inline bool operator!=(const name &lhs, const name &rhs) \
91 return static_cast<KCGroups::optional<typename name::value_type>>(lhs) != \
92 static_cast<KCGroups::optional<typename name::value_type>>(rhs); \
95 template<typename U> \
96 bool operator==(const name &lhs, const KCGroups::optional<U> &rhs) \
98 return static_cast<KCGroups::optional<typename name::value_type>>(lhs) == rhs; \
101 template<typename U> \
102 bool operator!=(const name &lhs, const KCGroups::optional<U> &rhs) \
104 return static_cast<KCGroups::optional<typename name::value_type>>(lhs) != rhs; \
107 template<typename T> \
108 bool operator==(const KCGroups::optional<T> &lhs, const name &rhs) \
110 return lhs == static_cast<KCGroups::optional<typename name::value_type>>(rhs); \
113 template<typename T> \
114 bool operator!=(const KCGroups::optional<T> &lhs, const name &rhs) \
116 return lhs != static_cast<KCGroups::optional<typename name::value_type>>(rhs); \
119 Q_DECLARE_METATYPE(name) \
120 static_assert(true, "")
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:52 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.