Skip to content

Commit 2ba38fe

Browse files
committed
Not allowing non-floating point types in core::radians and core::degrees functions
1 parent eff0ff4 commit 2ba38fe

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/nbl/core/math/glslFunctions.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,21 @@ class matrix3x4SIMD;
2828
template<typename T>
2929
NBL_FORCE_INLINE T radians(const T& degrees)
3030
{
31+
static_assert(
32+
std::is_same<T, float>::value ||
33+
std::is_same<T, double>::value,
34+
"This code expects the type to be double or float, only (float, double).");
35+
3136
return degrees*PI<T>()/T(180);
3237
}
3338
template<typename T>
3439
NBL_FORCE_INLINE T degrees(const T& radians)
3540
{
41+
static_assert(
42+
std::is_same<T, float>::value ||
43+
std::is_same<T, double>::value,
44+
"This code expects the type to be double or float, only (float, double).");
45+
3646
return radians*T(180)/PI<T>();
3747
}
3848
// TODO : sin,cos,tan,asin,acos,atan(y,x),atan(y_over_x),sinh,cosh,tanh,asinh,acosh,atanh,sincos

0 commit comments

Comments
 (0)