--- 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 <typename... Args> +struct QNonConstOverload +{ + template <typename R, typename T> + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } + template <typename R, typename T> + static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } +}; +template <typename... Args> +struct QConstOverload +{ + template <typename R, typename T> + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } + template <typename R, typename T> + static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } +}; +template <typename... Args> +struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...> +{ + using QConstOverload<Args...>::of; + using QConstOverload<Args...>::operator(); + using QNonConstOverload<Args...>::of; + using QNonConstOverload<Args...>::operator(); + template <typename R> + Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } + template <typename R> + static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) + { return ptr; } +}; +template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QOverload<Args...> qOverload = {}; +template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QConstOverload<Args...> qConstOverload = {}; +template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {}; +#endif + class Matrix; using GLRotationMatrix = QMatrix4x4; @@ -445,3 +485,14 @@ else flagset &= ~static_cast<T>(Flag); } + +/* + * Returns a singleton of type T, useful for providing a valid but unused + * pointer. + */ +template<typename T> +inline T& sink() +{ + static T result; + return result; +}