7#include <QtCore/qcompare_impl.h>
8#include <QtCore/qtypeinfo.h>
10#include <initializer_list>
21 constexpr inline Q_IMPLICIT operator int() const noexcept {
return i; }
23#if !defined(Q_CC_MSVC)
27# if !defined(__LP64__) && !defined(Q_QDOC)
44 constexpr inline Q_IMPLICIT operator int() const noexcept {
return i; }
51template<
typename Enum>
54 static_assert((
sizeof(Enum) <=
sizeof(
int)),
55 "QFlags uses an int as storage, so an enum with underlying "
56 "long long will overflow.");
57 static_assert((std::is_enum<Enum>::value),
"QFlags is only usable on enumeration types.");
60#if defined(Q_CC_MSVC) || defined(Q_QDOC)
65 typedef typename std::conditional<
66 std::is_unsigned<typename std::underlying_type<Enum>::type>
::value,
73 constexpr inline QFlags() noexcept : i(0) {}
77 constexpr inline QFlags(std::initializer_list<Enum>
flags) noexcept
78 :
i(initializer_list_helper(
flags.begin(),
flags.end())) {}
81 constexpr inline Int toInt() const noexcept {
return i; }
83#ifndef QT_TYPESAFE_FLAGS
94#ifdef QT_TYPESAFE_FLAGS
95 constexpr inline explicit operator Int() const noexcept {
return i; }
96 constexpr inline explicit operator bool() const noexcept {
return i; }
101 constexpr inline explicit operator QFlag() const noexcept {
return QFlag(i); }
104 constexpr inline bool operator!() const noexcept {
return !
i; }
111#ifndef QT_TYPESAFE_FLAGS
132 return on ? (*
this |= flag) : (*
this &=
~QFlags(flag));
136 {
return lhs.i == rhs.i; }
138 {
return lhs.i != rhs.i; }
140 {
return lhs ==
QFlags(rhs); }
142 {
return lhs !=
QFlags(rhs); }
144 {
return QFlags(lhs) == rhs; }
146 {
return QFlags(lhs) != rhs; }
148#ifdef QT_TYPESAFE_FLAGS
163 constexpr static inline Int initializer_list_helper(
typename std::initializer_list<Enum>::const_iterator
it,
164 typename std::initializer_list<Enum>::const_iterator
end)
174#define Q_DECLARE_FLAGS(Flags, Enum)\
175typedef QFlags<Enum> Flags;
178#ifdef QT_TYPESAFE_FLAGS
181#define QT_DECLARE_TYPESAFE_OPERATORS_FOR_FLAGS_ENUM(Flags) \
183constexpr inline Flags operator~(Flags::enum_type e) noexcept \
184{ return ~Flags(e); } \
186constexpr inline void operator|(Flags::enum_type f1, int f2) noexcept = delete;
188#define QT_DECLARE_TYPESAFE_OPERATORS_FOR_FLAGS_ENUM(Flags) \
190constexpr inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) noexcept \
191{ return QIncompatibleFlag(int(f1) | f2); }
194#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
196constexpr inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) noexcept \
197{ return QFlags<Flags::enum_type>(f1) | f2; } \
199constexpr inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept \
202constexpr inline QFlags<Flags::enum_type> operator&(Flags::enum_type f1, Flags::enum_type f2) noexcept \
203{ return QFlags<Flags::enum_type>(f1) & f2; } \
205constexpr inline QFlags<Flags::enum_type> operator&(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept \
208constexpr inline QFlags<Flags::enum_type> operator^(Flags::enum_type f1, Flags::enum_type f2) noexcept \
209{ return QFlags<Flags::enum_type>(f1) ^ f2; } \
211constexpr inline QFlags<Flags::enum_type> operator^(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept \
213constexpr inline void operator+(Flags::enum_type f1, Flags::enum_type f2) noexcept = delete; \
214constexpr inline void operator+(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept = delete; \
215constexpr inline void operator+(int f1, QFlags<Flags::enum_type> f2) noexcept = delete; \
216constexpr inline void operator-(Flags::enum_type f1, Flags::enum_type f2) noexcept = delete; \
217constexpr inline void operator-(Flags::enum_type f1, QFlags<Flags::enum_type> f2) noexcept = delete; \
218constexpr inline void operator-(int f1, QFlags<Flags::enum_type> f2) noexcept = delete; \
219constexpr inline void operator+(int f1, Flags::enum_type f2) noexcept = delete; \
220constexpr inline void operator+(Flags::enum_type f1, int f2) noexcept = delete; \
221constexpr inline void operator-(int f1, Flags::enum_type f2) noexcept = delete; \
222constexpr inline void operator-(Flags::enum_type f1, int f2) noexcept = delete; \
223QT_DECLARE_TYPESAFE_OPERATORS_FOR_FLAGS_ENUM(Flags)
227#if __cplusplus > 201702L
229# define Q_DECLARE_MIXED_ENUM_OPERATOR(op, Ret, LHS, RHS) \
231 constexpr inline Ret operator op (LHS lhs, RHS rhs) noexcept \
232 { return static_cast<Ret>(qToUnderlying(lhs) op qToUnderlying(rhs)); } \
237# define Q_DECLARE_MIXED_ENUM_OPERATOR(op, Ret, LHS, RHS) \
238 static_assert(std::is_same_v<decltype(std::declval<LHS>() op std::declval<RHS>()), Ret>);
241#define Q_DECLARE_MIXED_ENUM_OPERATORS(Ret, Flags, Enum) \
242 Q_DECLARE_MIXED_ENUM_OPERATOR(|, Ret, Flags, Enum) \
243 Q_DECLARE_MIXED_ENUM_OPERATOR(&, Ret, Flags, Enum) \
244 Q_DECLARE_MIXED_ENUM_OPERATOR(^, Ret, Flags, Enum) \
247#define Q_DECLARE_MIXED_ENUM_OPERATORS_SYMMETRIC(Ret, Flags, Enum) \
248 Q_DECLARE_MIXED_ENUM_OPERATORS(Ret, Flags, Enum) \
249 Q_DECLARE_MIXED_ENUM_OPERATORS(Ret, Enum, Flags) \
\inmodule QtCore\reentrant
constexpr Q_IMPLICIT QFlag(uint value) noexcept
constexpr Q_IMPLICIT QFlag(ushort value) noexcept
constexpr Q_IMPLICIT QFlag(short value) noexcept
constexpr Q_IMPLICIT QFlag(int value) noexcept
constexpr Q_IMPLICIT QFlag(ulong value) noexcept
constexpr Q_IMPLICIT QFlag(long value) noexcept
constexpr QFlags(std::initializer_list< Enum > flags) noexcept
constexpr QFlags & operator&=(Enum mask) noexcept
constexpr Q_IMPLICIT QFlags(Enum flags) noexcept
constexpr QFlags & operator&=(int mask) noexcept
constexpr void operator+(int other) const noexcept=delete
constexpr QFlags operator^(QFlags other) const noexcept
constexpr QFlags operator~() const noexcept
constexpr QFlags operator&(int mask) const noexcept
constexpr bool operator!() const noexcept
constexpr QFlags & operator|=(QFlags other) noexcept
constexpr Int toInt() const noexcept
constexpr QFlags & operator&=(uint mask) noexcept
friend constexpr bool operator!=(Enum lhs, QFlags rhs) noexcept
friend constexpr bool operator==(Enum lhs, QFlags rhs) noexcept
constexpr Q_IMPLICIT QFlags(QFlag flag) noexcept
constexpr void operator-(int other) const noexcept=delete
constexpr bool testFlag(Enum flag) const noexcept
constexpr QFlags & operator^=(Enum other) noexcept
friend constexpr bool operator==(QFlags lhs, Enum rhs) noexcept
constexpr bool testAnyFlag(Enum flag) const noexcept
constexpr bool testAnyFlags(QFlags flags) const noexcept
constexpr void operator+(Enum other) const noexcept=delete
constexpr void operator+(QFlags other) const noexcept=delete
std::conditional< std::is_unsigned< typenamestd::underlying_type< Enum >::type >::value, unsignedint, signedint >::type Int
friend constexpr bool operator!=(QFlags lhs, QFlags rhs) noexcept
constexpr QFlags & operator&=(QFlags mask) noexcept
constexpr QFlags operator|(Enum other) const noexcept
constexpr QFlags operator^(Enum other) const noexcept
constexpr QFlags & operator|=(Enum other) noexcept
constexpr void operator-(Enum other) const noexcept=delete
constexpr QFlags() noexcept
constexpr QFlags operator&(Enum other) const noexcept
friend constexpr bool operator!=(QFlags lhs, Enum rhs) noexcept
constexpr QFlags operator|(QFlags other) const noexcept
friend constexpr bool operator==(QFlags lhs, QFlags rhs) noexcept
constexpr void operator-(QFlags other) const noexcept=delete
constexpr QFlags operator&(QFlags other) const noexcept
static constexpr QFlags fromInt(Int i) noexcept
constexpr QFlags operator&(uint mask) const noexcept
constexpr QFlags & operator^=(QFlags other) noexcept
constexpr QFlags & setFlag(Enum flag, bool on=true) noexcept
constexpr bool testFlags(QFlags flags) const noexcept
constexpr QIncompatibleFlag(int i) noexcept
QSet< QString >::iterator it
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)