diff -r e5c1320e1018 -r 8d22e1dd272d src/basics.h --- a/src/basics.h Fri Mar 23 17:13:35 2018 +0200 +++ b/src/basics.h Fri Mar 23 17:14:46 2018 +0200 @@ -32,6 +32,46 @@ #include "macros.h" #include "transform.h" +#if (QT_VERSION < QT_VERSION_CHECK(5, 7, 0)) +template +struct QNonConstOverload +{ + template + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } + template + static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } +}; +template +struct QConstOverload +{ + template + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } + template + static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } +}; +template +struct QOverload : QConstOverload, QNonConstOverload +{ + using QConstOverload::of; + using QConstOverload::operator(); + using QNonConstOverload::of; + using QNonConstOverload::operator(); + template + Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } + template + static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } +}; +template Q_CONSTEXPR Q_DECL_UNUSED QOverload qOverload = {}; +template Q_CONSTEXPR Q_DECL_UNUSED QConstOverload qConstOverload = {}; +template Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload qNonConstOverload = {}; +#endif + class Matrix; using GLRotationMatrix = QMatrix4x4; @@ -445,3 +485,14 @@ else flagset &= ~static_cast(Flag); } + +/* + * Returns a singleton of type T, useful for providing a valid but unused + * pointer. + */ +template +inline T& sink() +{ + static T result; + return result; +}