From f4b3fc773347b7cf73e47751bd25ad27dd48cd50 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 7 Sep 2019 14:53:58 +0200 Subject: [PATCH] Added missing genType check for bitCount and bitfieldReverse #893 --- glm/detail/func_integer.inl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/glm/detail/func_integer.inl b/glm/detail/func_integer.inl index f4067ffc..091e1e0c 100644 --- a/glm/detail/func_integer.inl +++ b/glm/detail/func_integer.inl @@ -260,6 +260,8 @@ namespace detail template GLM_FUNC_QUALIFIER genIUType bitfieldInsert(genIUType const& Base, genIUType const& Insert, int Offset, int Bits) { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldInsert' only accept integer values"); + return bitfieldInsert(vec<1, genIUType>(Base), vec<1, genIUType>(Insert), Offset, Bits).x; } @@ -273,15 +275,19 @@ namespace detail } // bitfieldReverse - template - GLM_FUNC_QUALIFIER genType bitfieldReverse(genType x) + template + GLM_FUNC_QUALIFIER genIUType bitfieldReverse(genIUType x) { - return bitfieldReverse(glm::vec<1, genType, glm::defaultp>(x)).x; + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldReverse' only accept integer values"); + + return bitfieldReverse(glm::vec<1, genIUType, glm::defaultp>(x)).x; } template GLM_FUNC_QUALIFIER vec bitfieldReverse(vec const& v) { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldReverse' only accept integer values"); + vec x(v); x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 2>::call(x, static_cast(0x5555555555555555ull), static_cast( 1)); x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 4>::call(x, static_cast(0x3333333333333333ull), static_cast( 2)); @@ -293,15 +299,19 @@ namespace detail } // bitCount - template - GLM_FUNC_QUALIFIER int bitCount(genType x) + template + GLM_FUNC_QUALIFIER int bitCount(genIUType x) { - return bitCount(glm::vec<1, genType, glm::defaultp>(x)).x; + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitCount' only accept integer values"); + + return bitCount(glm::vec<1, genIUType, glm::defaultp>(x)).x; } template GLM_FUNC_QUALIFIER vec bitCount(vec const& v) { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitCount' only accept integer values"); + # if GLM_COMPILER & GLM_COMPILER_VC # pragma warning(push) # pragma warning(disable : 4310) //cast truncates constant value