Improved C++0x static_assert support

This commit is contained in:
Christophe Riccio 2010-11-12 18:58:55 +00:00
parent 8045560a26
commit 23ba487f03
13 changed files with 151 additions and 130 deletions

View File

@ -23,7 +23,7 @@ namespace glm
{
GLM_STATIC_ASSERT(
detail::type<genFIType>::is_float ||
detail::type<genFIType>::is_int);
detail::type<genFIType>::is_int, "'abs' only accept floating-point and integer inputs");
return x >= genFIType(0) ? x : -x;
}
};
@ -34,7 +34,7 @@ namespace glm
static genFIType get(genFIType const & x)
{
GLM_STATIC_ASSERT(
detail::type<genFIType>::is_uint);
detail::type<genFIType>::is_uint, "'abs' only accept floating-point and integer inputs");
return x;
}
@ -100,7 +100,7 @@ namespace glm
{
GLM_STATIC_ASSERT(
detail::type<genFIType>::is_float ||
detail::type<genFIType>::is_int);
detail::type<genFIType>::is_int, "'sign' only accept signed inputs");
genFIType result;
if(x > genFIType(0))
@ -152,7 +152,7 @@ namespace glm
template <typename genType>
inline genType floor(genType const& x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'floor' only accept floating-point inputs");
return ::std::floor(x);
}
@ -188,7 +188,7 @@ namespace glm
template <typename genType>
inline genType trunc(genType const & x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'trunc' only accept floating-point inputs");
return floor(abs(x));
}
@ -223,7 +223,7 @@ namespace glm
template <typename genType>
inline genType round(genType const& x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'round' only accept floating-point inputs");
return genType(int(x + genType(0.5)));
}
@ -259,7 +259,7 @@ namespace glm
template <typename genType>
inline genType roundEven(genType const& x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'roundEven' only accept floating-point inputs");
return genType(int(x + genType(int(x) % 2)));
}
@ -295,7 +295,7 @@ namespace glm
template <typename genType>
inline genType ceil(genType const & x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'ceil' only accept floating-point inputs");
return ::std::ceil(x);
}
@ -334,7 +334,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'fract' only accept floating-point inputs");
return x - ::std::floor(x);
}
@ -383,7 +383,7 @@ namespace glm
genType const & y
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mod' only accept floating-point inputs");
return x - y * floor(x / y);
}
@ -474,7 +474,7 @@ namespace glm
genType & i
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'modf' only accept floating-point inputs");
i = glm::floor(x);
@ -539,7 +539,7 @@ namespace glm
GLM_STATIC_ASSERT(
detail::type<genType>::is_float ||
detail::type<genType>::is_int ||
detail::type<genType>::is_uint);
detail::type<genType>::is_uint, "'min' only accept numbers");
return x < y ? x : y;
}
@ -633,7 +633,7 @@ namespace glm
GLM_STATIC_ASSERT(
detail::type<genType>::is_float ||
detail::type<genType>::is_int ||
detail::type<genType>::is_uint);
detail::type<genType>::is_uint, "'max' only accept numbers");
return x > y ? x : y;
}
@ -727,7 +727,7 @@ namespace glm
GLM_STATIC_ASSERT(
detail::type<valType>::is_float ||
detail::type<valType>::is_int ||
detail::type<valType>::is_uint);
detail::type<valType>::is_uint, "'clamp' only accept numbers");
if(x >= maxVal) return maxVal;
if(x <= minVal) return minVal;
@ -932,7 +932,7 @@ namespace glm
bool a
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mix' only accept floating-point inputs");
return a ? x : y;
}
@ -945,7 +945,7 @@ namespace glm
typename detail::tvec2<T>::bool_type a
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'mix' only accept floating-point inputs");
detail::tvec2<T> result;
for
@ -968,7 +968,7 @@ namespace glm
typename detail::tvec3<T>::bool_type a
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'mix' only accept floating-point inputs");
detail::tvec3<T> result;
for
@ -991,7 +991,7 @@ namespace glm
typename detail::tvec4<T>::bool_type a
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'mix' only accept floating-point inputs");
detail::tvec4<T> result;
for
@ -1014,7 +1014,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mix' only accept floating-point inputs");
return x <= edge ? genType(0) : genType(1);
}
@ -1106,7 +1106,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mix' only accept floating-point inputs");
genType tmp = clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1));
return tmp * tmp * (genType(3) - genType(2) * tmp);
@ -1202,7 +1202,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mix' only accept floating-point inputs");
#if(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC)
return typename genType::bool_type(_isnan(x));
@ -1253,7 +1253,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'isinf' only accept floating-point inputs");
#if(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC)
return typename genType::bool_type(_fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF);

View File

@ -21,7 +21,7 @@ namespace glm
genType const & y
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'pow' only accept floating-point input");
return ::std::pow(x, y);
}
@ -72,7 +72,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'exp' only accept floating-point input");
return ::std::exp(x);
}
@ -120,7 +120,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'log' only accept floating-point input");
return ::std::log(x);
}
@ -168,7 +168,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'exp2' only accept floating-point input");
return ::std::exp(genType(0.69314718055994530941723212145818) * x);
}
@ -216,7 +216,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'log2' only accept floating-point input");
return ::std::log(x) / genType(0.69314718055994530941723212145818);
}
@ -264,9 +264,9 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sqrt' only accept floating-point input");
return genType(::std::sqrt(double(x)));
return genType(::std::sqrt(x));
}
template <typename T>
@ -311,7 +311,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'inversesqrt' only accept floating-point input");
return genType(1) / ::std::sqrt(x);
}

View File

@ -20,7 +20,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'length' only accept floating-point inputs");
genType sqr = x * x;
return sqrt(sqr);
@ -32,7 +32,7 @@ namespace glm
detail::tvec2<T> const & v
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'length' only accept floating-point inputs");
typename detail::tvec2<T>::value_type sqr = v.x * v.x + v.y * v.y;
return sqrt(sqr);
@ -44,7 +44,7 @@ namespace glm
detail::tvec3<T> const & v
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'length' only accept floating-point inputs");
typename detail::tvec3<T>::value_type sqr = v.x * v.x + v.y * v.y + v.z * v.z;
return sqrt(sqr);
@ -56,7 +56,7 @@ namespace glm
detail::tvec4<T> const & v
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'length' only accept floating-point inputs");
typename detail::tvec4<T>::value_type sqr = v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w;
return sqrt(sqr);
@ -70,7 +70,7 @@ namespace glm
genType const & p1
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'distance' only accept floating-point inputs");
return length(p1 - p0);
}
@ -82,7 +82,7 @@ namespace glm
detail::tvec2<T> const & p1
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'distance' only accept floating-point inputs");
return length(p1 - p0);
}
@ -94,7 +94,7 @@ namespace glm
detail::tvec3<T> const & p1
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'distance' only accept floating-point inputs");
return length(p1 - p0);
}
@ -106,7 +106,7 @@ namespace glm
detail::tvec4<T> const & p1
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'distance' only accept floating-point inputs");
return length(p1 - p0);
}
@ -119,7 +119,7 @@ namespace glm
genType const & y
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'dot' only accept floating-point inputs");
return x * y;
}
@ -131,7 +131,7 @@ namespace glm
detail::tvec2<T> const & y
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'dot' only accept floating-point inputs");
return x.x * y.x + x.y * y.y;
}
@ -143,7 +143,7 @@ namespace glm
detail::tvec3<T> const & y
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'dot' only accept floating-point inputs");
return x.x * y.x + x.y * y.y + x.z * y.z;
}
@ -171,7 +171,7 @@ namespace glm
detail::tvec4<T> const & y
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'dot' only accept floating-point inputs");
return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w;
}
@ -184,7 +184,7 @@ namespace glm
detail::tvec3<T> const & y
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'cross' only accept floating-point inputs");
return detail::tvec3<T>(
x.y * y.z - y.y * x.z,
@ -199,7 +199,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'normalize' only accept floating-point inputs");
return x < genType(0) ? genType(-1) : genType(1);
}
@ -211,7 +211,7 @@ namespace glm
detail::tvec2<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'normalize' only accept floating-point inputs");
typename detail::tvec2<T>::value_type sqr = x.x * x.x + x.y * x.y;
return x * inversesqrt(sqr);
@ -223,7 +223,7 @@ namespace glm
detail::tvec3<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'normalize' only accept floating-point inputs");
typename detail::tvec3<T>::value_type sqr = x.x * x.x + x.y * x.y + x.z * x.z;
return x * inversesqrt(sqr);
@ -235,7 +235,7 @@ namespace glm
detail::tvec4<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'normalize' only accept floating-point inputs");
typename detail::tvec4<T>::value_type sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w;
return x * inversesqrt(sqr);

View File

@ -266,7 +266,7 @@ namespace glm
int const & Bits
)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldExtract' only accept integer values");
assert(Offset + Bits <= sizeof(genIUType));
genIUType Result = 0;
@ -332,7 +332,7 @@ namespace glm
int const & Bits
)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldInsert' only accept integer values");
assert(Offset + Bits <= sizeof(genIUType));
if(Bits == 0)
@ -394,7 +394,7 @@ namespace glm
template <typename genIUType>
inline genIUType bitfieldReverse(genIUType const & Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldReverse' only accept integer values");
genIUType Result = 0;
for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i)
@ -443,7 +443,7 @@ namespace glm
template <typename genIUType>
int bitCount(genIUType const & Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitCount' only accept integer values");
int Count = 0;
for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i)
@ -497,7 +497,7 @@ namespace glm
genIUType const & Value
)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findLSB' only accept integer values");
if(Value == 0)
return -1;
@ -549,7 +549,7 @@ namespace glm
genIUType const & Value
)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
if(Value == 0)
return -1;

View File

@ -21,7 +21,7 @@ namespace glm
matType const & y
)
{
GLM_STATIC_ASSERT(detail::type<typename matType::value_type>::is_float);
GLM_STATIC_ASSERT(detail::type<typename matType::value_type>::is_float, "'matrixCompMult' only accept floating-point inputs");
matType result(matType::null);
for(typename matType::size_type i = 0; i < matType::col_size(); ++i)
@ -37,7 +37,7 @@ namespace glm
detail::tvec2<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat2x2<T> m(detail::tmat2x2<T>::null);
m[0][0] = c[0] * r[0];
@ -54,7 +54,7 @@ namespace glm
detail::tvec3<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat3x3<T> m(detail::tmat3x3<T>::null);
for(typename detail::tmat3x3<T>::size_type i = 0; i < detail::tmat3x3<T>::col_size(); ++i)
@ -69,7 +69,7 @@ namespace glm
detail::tvec4<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat4x4<T> m(detail::tmat4x4<T>::null);
for(typename detail::tmat4x4<T>::size_type i = 0; i < detail::tmat4x4<T>::col_size(); ++i)
@ -84,7 +84,7 @@ namespace glm
detail::tvec2<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat2x3<T> m(detail::tmat2x3<T>::null);
m[0][0] = c.x * r.x;
@ -103,7 +103,7 @@ namespace glm
detail::tvec3<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat3x2<T> m(detail::tmat3x2<T>::null);
m[0][0] = c.x * r.x;
@ -122,7 +122,7 @@ namespace glm
detail::tvec4<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat2x4<T> m(detail::tmat2x4<T>::null);
m[0][0] = c.x * r.x;
@ -143,7 +143,7 @@ namespace glm
detail::tvec2<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat4x2<T> m(detail::tmat4x2<T>::null);
m[0][0] = c.x * r.x;
@ -164,7 +164,7 @@ namespace glm
detail::tvec3<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat3x4<T> m(detail::tmat3x4<T>::null);
m[0][0] = c.x * r.x;
@ -189,7 +189,7 @@ namespace glm
detail::tvec4<T> const & r
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat4x3<T> m(detail::tmat4x3<T>::null);
m[0][0] = c.x * r.x;
@ -213,7 +213,7 @@ namespace glm
detail::tmat2x2<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat2x2<T> result(detail::tmat2x2<T>::null);
result[0][0] = m[0][0];
@ -229,7 +229,7 @@ namespace glm
detail::tmat3x3<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat3x3<T> result(detail::tmat3x3<T>::null);
result[0][0] = m[0][0];
@ -252,7 +252,7 @@ namespace glm
detail::tmat4x4<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat4x4<T> result(detail::tmat4x4<T>::null);
result[0][0] = m[0][0];
@ -283,7 +283,7 @@ namespace glm
detail::tmat3x2<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat2x3<T> result(detail::tmat2x3<T>::null);
result[0][0] = m[0][0];
@ -301,7 +301,7 @@ namespace glm
detail::tmat2x3<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat3x2<T> result(detail::tmat3x2<T>::null);
result[0][0] = m[0][0];
@ -319,7 +319,7 @@ namespace glm
detail::tmat4x2<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat2x4<T> result(detail::tmat2x4<T>::null);
result[0][0] = m[0][0];
@ -339,7 +339,7 @@ namespace glm
detail::tmat2x4<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat4x2<T> result(detail::tmat4x2<T>::null);
result[0][0] = m[0][0];
@ -359,7 +359,7 @@ namespace glm
detail::tmat4x3<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat3x4<T> result(detail::tmat3x4<T>::null);
result[0][0] = m[0][0];
@ -383,7 +383,7 @@ namespace glm
detail::tmat3x4<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat4x3<T> result(detail::tmat4x3<T>::null);
result[0][0] = m[0][0];
@ -407,6 +407,8 @@ namespace glm
detail::tmat2x2<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'determinant' only accept floating-point inputs");
return m[0][0] * m[1][1] - m[1][0] * m[0][1];
}
@ -416,6 +418,8 @@ namespace glm
detail::tmat3x3<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'determinant' only accept floating-point inputs");
return
+ m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2])
- m[1][0] * (m[0][1] * m[2][2] - m[2][1] * m[0][2])
@ -428,6 +432,8 @@ namespace glm
detail::tmat4x4<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'determinant' only accept floating-point inputs");
T SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
T SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
T SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
@ -453,6 +459,8 @@ namespace glm
detail::tmat2x2<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'inverse' only accept floating-point inputs");
//valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
T Determinant = determinant(m);
@ -471,6 +479,8 @@ namespace glm
detail::tmat3x3<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'inverse' only accept floating-point inputs");
//valType Determinant = m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2])
// - m[1][0] * (m[0][1] * m[2][2] - m[2][1] * m[0][2])
// + m[2][0] * (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
@ -498,6 +508,8 @@ namespace glm
detail::tmat4x4<T> const & m
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'inverse' only accept floating-point inputs");
T Coef00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
T Coef02 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
T Coef03 = m[1][2] * m[2][3] - m[2][2] * m[1][3];

View File

@ -20,7 +20,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'noise1' only accept floating-point values");
int iNbr = int(x + genType(3) / genType(2)) * 1103515245 + 12345;
return genType(int(iNbr / genType(65536)) % 32768) / genType(32767);
@ -69,7 +69,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'noise2' only accept floating-point values");
genType f1 = x * genType(1103515245) + genType(12345);
genType f2 = f1 * genType(1103515245) + genType(12345);
@ -84,7 +84,7 @@ namespace glm
detail::tvec2<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise2' only accept floating-point values");
T f0(0);
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
@ -103,7 +103,7 @@ namespace glm
detail::tvec3<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise2' only accept floating-point values");
T f0(0);
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
@ -122,7 +122,7 @@ namespace glm
detail::tvec4<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise2' only accept floating-point values");
T f0(0);
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
@ -142,7 +142,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'noise3' only accept floating-point values");
genType f1 = x * genType(1103515245) + genType(12345);
genType f2 = f1 * genType(1103515245) + genType(12345);
@ -159,7 +159,7 @@ namespace glm
detail::tvec2<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise3' only accept floating-point values");
T f0(0);
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
@ -179,7 +179,7 @@ namespace glm
detail::tvec3<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise3' only accept floating-point values");
T f0(0);
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
@ -199,7 +199,7 @@ namespace glm
detail::tvec4<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise3' only accept floating-point values");
T f0(0);
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
@ -220,7 +220,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'noise4' only accept floating-point values");
genType f1 = x * genType(1103515245) + genType(12345);
genType f2 = f1 * genType(1103515245) + genType(12345);
@ -239,7 +239,7 @@ namespace glm
detail::tvec2<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise4' only accept floating-point values");
T f0(0);
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
@ -261,7 +261,7 @@ namespace glm
detail::tvec3<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise4' only accept floating-point values");
T f0(0);
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size()(); ++i)
@ -283,7 +283,7 @@ namespace glm
detail::tvec4<T> const & x
)
{
GLM_STATIC_ASSERT(detail::type<T>::is_float);
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'noise4' only accept floating-point values");
T f0(0);
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size()(); ++i)

View File

@ -211,7 +211,7 @@ namespace glm
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'tan' only accept floating-point input");
return ::std::tan(angle);
}
@ -259,7 +259,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asin' only accept floating-point input");
return ::std::asin(x);
}
@ -307,7 +307,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acos' only accept floating-point input");
return ::std::acos(x);
}
@ -356,7 +356,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atan' only accept floating-point input");
return ::std::atan2(y, x);
}
@ -406,7 +406,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atan' only accept floating-point input");
return ::std::atan(x);
}
@ -454,7 +454,7 @@ namespace glm
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sinh' only accept floating-point input");
return std::sinh(angle);
}
@ -502,7 +502,7 @@ namespace glm
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cosh' only accept floating-point input");
return std::cosh(angle);
}
@ -550,7 +550,7 @@ namespace glm
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'tanh' only accept floating-point input");
return std::tanh(angle);
}
@ -598,7 +598,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asinh' only accept floating-point input");
return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x));
}
@ -646,7 +646,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acosh' only accept floating-point input");
if(x < genType(1))
return genType(0);
@ -696,7 +696,7 @@ namespace glm
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atanh' only accept floating-point input");
if(abs(x) >= genType(1))
return 0;

View File

@ -34,7 +34,7 @@ namespace glm
GLM_STATIC_ASSERT(
detail::type<T>::is_float ||
detail::type<T>::is_int ||
detail::type<T>::is_uint);
detail::type<T>::is_uint, "'lessThan' only accept numbers");
typename vecType<bool>::bool_type Result(vecType<bool>::null);
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
@ -54,7 +54,7 @@ namespace glm
GLM_STATIC_ASSERT(
detail::type<T>::is_float ||
detail::type<T>::is_int ||
detail::type<T>::is_uint);
detail::type<T>::is_uint, "'lessThanEqual' only accept numbers");
typename vecType<bool>::bool_type Result(vecType<bool>::null);
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
@ -74,7 +74,7 @@ namespace glm
GLM_STATIC_ASSERT(
detail::type<T>::is_float ||
detail::type<T>::is_int ||
detail::type<T>::is_uint);
detail::type<T>::is_uint, "'greaterThan' only accept numbers");
typename vecType<bool>::bool_type Result(vecType<bool>::null);
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
@ -94,7 +94,7 @@ namespace glm
GLM_STATIC_ASSERT(
detail::type<T>::is_float ||
detail::type<T>::is_int ||
detail::type<T>::is_uint);
detail::type<T>::is_uint, "'greaterThanEqual' only accept numbers");
typename vecType<bool>::bool_type Result(vecType<bool>::null);
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
@ -115,7 +115,7 @@ namespace glm
detail::type<T>::is_float ||
detail::type<T>::is_int ||
detail::type<T>::is_uint ||
detail::type<T>::is_bool);
detail::type<T>::is_bool, "'equal' only accept GLM vectors");
typename vecType<bool>::bool_type Result(vecType<bool>::null);
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
@ -136,7 +136,7 @@ namespace glm
detail::type<T>::is_float ||
detail::type<T>::is_int ||
detail::type<T>::is_uint ||
detail::type<T>::is_bool);
detail::type<T>::is_bool, "'notEqual' only accept GLM vectors");
typename vecType<bool>::bool_type Result(vecType<bool>::null);
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
@ -149,6 +149,9 @@ namespace glm
template <template <typename> class vecType>
inline bool any(vecType<bool> const & v)
{
GLM_STATIC_ASSERT(
detail::type<T>::is_bool, "'any' only accept GLM boolean vectors");
bool Result = false;
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
Result = Result || v[i];
@ -160,6 +163,9 @@ namespace glm
template <template <typename> class vecType>
inline bool all(vecType<bool> const & v)
{
GLM_STATIC_ASSERT(
detail::type<T>::is_bool, "'all' only accept GLM boolean vectors");
bool Result = true;
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
Result = Result && v[i];
@ -171,6 +177,9 @@ namespace glm
template <template <typename> class vecType>
inline vecType<bool> not_(vecType<bool> const & v)
{
GLM_STATIC_ASSERT(
detail::type<T>::is_bool, "'not_' only accept GLM boolean vectors");
typename vecType<bool>::bool_type Result(vecType<bool>::null);
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
Result[i] = !v[i];

View File

@ -119,19 +119,19 @@ namespace glm
////////////////////
// check type sizes
#ifndef GLM_STATIC_ASSERT_NULL
GLM_STATIC_ASSERT(sizeof(glm::detail::int8)==1);
GLM_STATIC_ASSERT(sizeof(glm::detail::int16)==2);
GLM_STATIC_ASSERT(sizeof(glm::detail::int32)==4);
GLM_STATIC_ASSERT(sizeof(glm::detail::int64)==8);
GLM_STATIC_ASSERT(sizeof(glm::detail::int8)==1, "int8 size isn't 1 byte on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::int16)==2, "int16 size isn't 2 bytes on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::int32)==4, "int32 size isn't 4 bytes on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::int64)==8, "int64 size isn't 8 bytes on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::uint8)==1);
GLM_STATIC_ASSERT(sizeof(glm::detail::uint16)==2);
GLM_STATIC_ASSERT(sizeof(glm::detail::uint32)==4);
GLM_STATIC_ASSERT(sizeof(glm::detail::uint64)==8);
GLM_STATIC_ASSERT(sizeof(glm::detail::uint8)==1, "uint8 size isn't 1 byte on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::uint16)==2, "uint16 size isn't 2 bytes on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::uint32)==4, "uint32 size isn't 4 bytes on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::uint64)==8, "uint64 size isn't 8 bytes on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::float16)==2);
GLM_STATIC_ASSERT(sizeof(glm::detail::float32)==4);
GLM_STATIC_ASSERT(sizeof(glm::detail::float64)==8);
GLM_STATIC_ASSERT(sizeof(glm::detail::float16)==2, "float16 size isn't 2 bytes on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::float32)==4, "float32 size isn't 4 bytes on this platform");
GLM_STATIC_ASSERT(sizeof(glm::detail::float64)==8, "float64 size isn't 8 bytes on this platform");
#endif//GLM_STATIC_ASSERT_NULL
#endif //glm_glm

View File

@ -25,7 +25,7 @@ namespace matrix_access
template <typename genType>
inline typename genType::row_type row(
genType & const m,
genType const & m,
int index)
{
typename genType::row_type Result;

View File

@ -596,7 +596,7 @@ inline detail::tvec4<valType> powerOfTwoNearest
template <typename genType>
inline genType bitRevert(genType const & In)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRevert' only accept integer values");
genType Out = 0;
std::size_t BitSize = sizeof(genType) * 8;
@ -645,7 +645,7 @@ inline detail::tvec4<valType> bitRevert
template <typename genType>
inline genType bitRotateRight(genType const & In, std::size_t Shift)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateRight' only accept integer values");
std::size_t BitSize = sizeof(genType) * 8;
return (In << Shift) | (In >> (BitSize - Shift));
@ -693,7 +693,7 @@ inline detail::tvec4<valType> bitRotateRight
template <typename genType>
inline genType bitRotateLeft(genType const & In, std::size_t Shift)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer);
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateLeft' only accept integer values");
std::size_t BitSize = sizeof(genType) * 8;
return (In >> Shift) | (In << (BitSize - Shift));

View File

@ -18,7 +18,7 @@ inline genType sec
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sec' only accept floating-point values");
return genType(1) / glm::cos(angle);
}
@ -66,7 +66,7 @@ inline genType csc
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csc' only accept floating-point values");
return genType(1) / glm::sin(angle);
}
@ -114,7 +114,7 @@ inline genType cot
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cot' only accept floating-point values");
return genType(1) / glm::tan(angle);
}
@ -162,7 +162,7 @@ inline genType asec
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asec' only accept floating-point values");
return acos(genType(1) / x);
}
@ -210,7 +210,7 @@ inline genType acsc
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsc' only accept floating-point values");
return asin(genType(1) / x);
}
@ -258,7 +258,7 @@ inline genType acot
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acot' only accept floating-point values");
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
return pi_over_2 - atan(x);
@ -307,7 +307,7 @@ inline genType sech
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sech' only accept floating-point values");
return genType(1) / glm::cosh(angle);
}
@ -355,7 +355,7 @@ inline genType csch
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csch' only accept floating-point values");
return genType(1) / glm::sinh(angle);
}
@ -403,7 +403,7 @@ inline genType coth
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'coth' only accept floating-point values");
return glm::cosh(angle) / glm::sinh(angle);
}
@ -451,7 +451,7 @@ inline genType asech
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asech' only accept floating-point values");
return acosh(genType(1) / x);
}
@ -499,7 +499,7 @@ inline genType acsch
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsch' only accept floating-point values");
return asinh(genType(1) / x);
}
@ -547,7 +547,7 @@ inline genType acoth
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float);
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acoth' only accept floating-point values");
return atanh(genType(1) / x);
}

View File

@ -248,7 +248,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Static assert
#if(defined(GLM_LANGUAGE) && GLM_LANGUAGE == GLM_LANGUAGE_CPP0X)
#if(GLM_COMPILER >= GLM_COMPILER_VC2010 || GLM_COMPILER >= GLM_COMPILER_GCC45)
#define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
#elif(defined(BOOST_STATIC_ASSERT))
#define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x)