src/basics.h

changeset 51
1a9eac27698d
parent 33
4c41bfe2ec6e
child 53
3af627f7a40f
equal deleted inserted replaced
50:0f80a2e5e42b 51:1a9eac27698d
83 constexpr int countof(T(&)[N]) 83 constexpr int countof(T(&)[N])
84 { 84 {
85 return N; 85 return N;
86 } 86 }
87 87
88 /**
89 * @brief casts @c x to a suitable unsigned integer
90 */
91 template<typename T>
92 constexpr auto unsigned_cast(T x)
93 -> std::enable_if_t<std::is_integral_v<T>, std::make_unsigned_t<T>>
94 {
95 return static_cast<std::make_unsigned_t<T>>(x);
96 }
97
98 /**
99 * @brief casts @c x to a suitable signed integer
100 */
101 template<typename T>
102 constexpr auto signed_cast(T x)
103 -> std::enable_if_t<std::is_integral_v<T>, std::make_signed_t<T>>
104 {
105 return static_cast<std::make_signed_t<T>>(x);
106 }
107
88 Q_DECLARE_METATYPE(glm::vec3) 108 Q_DECLARE_METATYPE(glm::vec3)
89 Q_DECLARE_METATYPE(glm::mat4) 109 Q_DECLARE_METATYPE(glm::mat4)

mercurial