mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-27 08:19:47 -05:00
Add Q_STATIC_ASSERT macro, backported from Qt 5.
This commit is contained in:
parent
6ce53b142d
commit
85031658d1
@ -42,6 +42,9 @@
|
|||||||
# if __has_feature(cxx_nullptr)
|
# if __has_feature(cxx_nullptr)
|
||||||
# define COMPILER_NULLPTR
|
# define COMPILER_NULLPTR
|
||||||
# endif
|
# endif
|
||||||
|
# if __has_feature(cxx_static_assert)
|
||||||
|
# define COMPILER_STATIC_ASSERT
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif // Q_CC_CLANG
|
#endif // Q_CC_CLANG
|
||||||
|
|
||||||
@ -50,6 +53,7 @@
|
|||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
|
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
|
||||||
/* C++11 features supported in GCC 4.3: */
|
/* C++11 features supported in GCC 4.3: */
|
||||||
# define COMPILER_DECLTYPE
|
# define COMPILER_DECLTYPE
|
||||||
|
# define COMPILER_STATIC_ASSERT
|
||||||
# endif
|
# endif
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
|
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
|
||||||
# define COMPILER_CLASS_ENUM
|
# define COMPILER_CLASS_ENUM
|
||||||
@ -99,4 +103,21 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(Q_STATIC_ASSERT) && !defined(Q_STATIC_ASSERT_X)
|
||||||
|
#ifdef COMPILER_STATIC_ASSERT
|
||||||
|
#define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
|
||||||
|
#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
|
||||||
|
#else
|
||||||
|
// Intentionally undefined
|
||||||
|
template <bool Test> class QStaticAssertFailure;
|
||||||
|
template <> class QStaticAssertFailure<true> {};
|
||||||
|
|
||||||
|
#define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
|
||||||
|
#define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
|
||||||
|
#define Q_STATIC_ASSERT(Condition) \
|
||||||
|
enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
|
||||||
|
#define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
|
||||||
|
#endif // COMPILER_STATIC_ASSERT
|
||||||
|
#endif // !defined(Q_STATIC_ASSERT) && !defined(Q_STATIC_ASSERT_X)
|
||||||
|
|
||||||
#endif // KEEPASSX_GLOBAL_H
|
#endif // KEEPASSX_GLOBAL_H
|
||||||
|
Loading…
Reference in New Issue
Block a user