diff -r eee644f88e93 -r 3af627f7a40f src/basics.h --- a/src/basics.h Sat Feb 08 00:08:57 2020 +0200 +++ b/src/basics.h Thu Feb 13 12:51:27 2020 +0200 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -105,5 +106,32 @@ return static_cast>(x); } + +/** +* @brief casts double and long double - and only those types - to float +* @param[in] x double or long double to cast +* @returns float +*/ +template +auto doubleToFloat(T x) + -> std::enable_if_t< + std::is_same_v, double> || + std::is_same_v, long double + >, float> +{ + return static_cast(x); +} + +/** +* @brief Casts float - and only float - to double +* @param[in] x float to cast +* @returns double +*/ +template +auto floatToDouble(T x) + -> std::enable_if_t, float>, double> +{ + return static_cast(x); +} Q_DECLARE_METATYPE(glm::vec3) Q_DECLARE_METATYPE(glm::mat4)