diff -r 06a1aef170aa -r 165777a20dc7 src/basics.h --- a/src/basics.h Thu Nov 05 14:29:58 2020 +0200 +++ b/src/basics.h Sun Jan 10 15:28:44 2021 +0200 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -162,9 +163,26 @@ return {point.x(), point.y()}; } -constexpr float PIf = static_cast(M_PI); -constexpr double PI = M_PI; -constexpr long double PIl = M_PIl; +/* + * coalesce(arg1, arg2, ..., argn) + * Returns the first of the given arguments that evaluates to true. + */ +template +T coalesce(T&& arg) +{ + // recursion base: 1 argument + return arg; +} + +template +std::common_type_t coalesce(T&& arg, Rest&&... rest) +{ + // general case: n arguments + return arg ? arg : coalesce(rest...); +} + +template +constexpr std::enable_if_t, T> PI = static_cast(M_PIl); Q_DECLARE_METATYPE(glm::vec3) Q_DECLARE_METATYPE(glm::mat4)