Fixed constexpr build...

master
Christophe Riccio ago%!(EXTRA string=7 years)
parent 6d34ae4c5e
commit 13ca6771ca
  1. 76
      glm/detail/func_vector_relational.inl
  2. 1
      test/core/core_cpp_constexpr.cpp
  3. 8
      test/core/core_func_common.cpp
  4. 4
      test/core/core_type_mat3x3.cpp
  5. 1
      test/core/core_type_vec3.cpp
  6. 1
      test/core/core_type_vec4.cpp
  7. 4
      test/ext/ext_scalar_relational.cpp

@ -122,6 +122,25 @@ namespace detail
} }
}; };
template<length_t I, length_t N, relational_type R>
struct loop_relational
{
template<typename vecBType, typename vecType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(vecBType& Dst, vecType const& Src0, vecType const& Src1)
{
Dst[I] = relational<R>::call(Src0[I], Src1[I]);
loop_relational<I + 1, N, R>::call(Dst, Src0, Src1);
}
};
template <length_t N, relational_type R>
struct loop_relational<N, N, R>
{
template<typename vecBType, typename vecType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(vecBType&, vecType const&, vecType const&)
{}
};
template<length_t I, length_t N, relational_type R> template<length_t I, length_t N, relational_type R>
struct reduce_relational struct reduce_relational
{ {
@ -140,26 +159,31 @@ namespace detail
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(bool&, vecType const&) GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(bool&, vecType const&)
{} {}
}; };
}//namespace detail
template<length_t I, length_t N, relational_type R> template<length_t L, qualifier Q>
struct loop_relational GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool any(vec<L, bool, Q> const& v)
{ {
template<typename vecBType, typename vecType> bool Result = false;
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(vecBType& Dst, vecType const& Src0, vecType const& Src1) detail::reduce_relational<0, L, detail::ANY>::call(Result, v);
return Result;
}
template<length_t L, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool all(vec<L, bool, Q> const& v)
{ {
Dst[I] = relational<R>::call(Src0[I], Src1[I]); bool Result = true;
loop_relational<I + 1, N, R>::call(Dst, Src0, Src1); detail::reduce_relational<0, L, detail::ALL>::call(Result, v);
return Result;
} }
};
template <length_t N, relational_type R> template<length_t L, qualifier Q>
struct loop_relational<N, N, R> GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> not_(vec<L, bool, Q> const& v)
{ {
template<typename vecBType, typename vecType> vec<L, bool, Q> Result;
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static void call(vecBType&, vecType const&, vecType const&) detail::loop_relational<0, L, detail::NOT>::call(Result, v, v);
{} return Result;
}; }
}//namespace detail
template<length_t L, typename T, qualifier Q> template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> lessThan(vec<L, T, Q> const& x, vec<L, T, Q> const& y) GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> lessThan(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
@ -208,30 +232,6 @@ namespace detail
detail::loop_relational<0, L, detail::NOT_EQUAL>::call(Result, x, y); detail::loop_relational<0, L, detail::NOT_EQUAL>::call(Result, x, y);
return Result; return Result;
} }
template<length_t L, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool any(vec<L, bool, Q> const& v)
{
bool Result = false;
detail::reduce_relational<0, L, detail::ANY>::call(Result, v);
return Result;
}
template<length_t L, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool all(vec<L, bool, Q> const& v)
{
bool Result = true;
detail::reduce_relational<0, L, detail::ALL>::call(Result, v);
return Result;
}
template<length_t L, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> not_(vec<L, bool, Q> const& v)
{
vec<L, bool, Q> Result;
detail::loop_relational<0, L, detail::NOT>::call(Result, v, v);
return Result;
}
}//namespace glm }//namespace glm
#if GLM_CONFIG_SIMD == GLM_ENABLE #if GLM_CONFIG_SIMD == GLM_ENABLE

@ -650,7 +650,6 @@ static int test_quat()
glm::quat constexpr Q = glm::identity<glm::quat>(); glm::quat constexpr Q = glm::identity<glm::quat>();
static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon<float>(), "GLM: Failed constexpr"); static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon<float>(), "GLM: Failed constexpr");
static_assert(Q[0] == 0, "GLM: Failed constexpr");
} }
return Error; return Error;

@ -1298,10 +1298,10 @@ static int test_constexpr()
{ {
#if GLM_HAS_CONSTEXPR #if GLM_HAS_CONSTEXPR
static_assert(glm::abs(1.0f) > 0.0f, "GLM: Failed constexpr"); static_assert(glm::abs(1.0f) > 0.0f, "GLM: Failed constexpr");
static_assert(glm::abs(glm::vec1(1.0f)) != glm::vec1(0.0f), "GLM: Failed constexpr"); constexpr glm::vec1 const A = glm::abs(glm::vec1(1.0f));
static_assert(glm::abs(glm::vec2(1.0f)) != glm::vec2(0.0f), "GLM: Failed constexpr"); constexpr glm::vec2 const B = glm::abs(glm::vec2(1.0f));
static_assert(glm::abs(glm::vec3(1.0f)) != glm::vec3(0.0f), "GLM: Failed constexpr"); constexpr glm::vec3 const C = glm::abs(glm::vec3(1.0f));
static_assert(glm::abs(glm::vec4(1.0f)) != glm::vec4(0.0f), "GLM: Failed constexpr"); constexpr glm::vec4 const D = glm::abs(glm::vec4(1.0f));
#endif // GLM_HAS_CONSTEXPR #endif // GLM_HAS_CONSTEXPR
return 0; return 0;

@ -187,9 +187,7 @@ static int test_constexpr()
#if GLM_HAS_CONSTEXPR #if GLM_HAS_CONSTEXPR
static_assert(glm::mat3x3::length() == 3, "GLM: Failed constexpr"); static_assert(glm::mat3x3::length() == 3, "GLM: Failed constexpr");
GLM_CONSTEXPR glm::mat3x3 const Z(0.0f); constexpr glm::mat3x3 const Z(0.0f);
static_assert(Z[0] == glm::vec3(0.0f), "GLM: Failed constexpr");
static_assert(Z == glm::mat3x3(0.0f), "GLM: Failed constexpr");
#endif #endif
return 0; return 0;

@ -600,7 +600,6 @@ static int test_constexpr()
#if GLM_HAS_CONSTEXPR #if GLM_HAS_CONSTEXPR
static_assert(glm::vec3::length() == 3, "GLM: Failed constexpr"); static_assert(glm::vec3::length() == 3, "GLM: Failed constexpr");
static_assert(glm::vec3(1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f).x > 0.0f, "GLM: Failed constexpr");
static_assert(glm::vec3(1.0f) == glm::vec3(1.0f), "GLM: Failed constexpr");
static_assert(glm::vec3(1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
static_assert(glm::vec3(1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
#endif #endif

@ -754,7 +754,6 @@ static int test_constexpr()
#if GLM_HAS_CONSTEXPR #if GLM_HAS_CONSTEXPR
static_assert(glm::vec4::length() == 4, "GLM: Failed constexpr"); static_assert(glm::vec4::length() == 4, "GLM: Failed constexpr");
static_assert(glm::vec4(1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec4(1.0f).x > 0.0f, "GLM: Failed constexpr");
static_assert(glm::vec4(1.0f) == glm::vec4(1.0f), "GLM: Failed constexpr");
static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
#endif #endif

@ -2,8 +2,10 @@
int test_equal() int test_equal()
{ {
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
static_assert(glm::equal(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr"); static_assert(glm::equal(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr");
static_assert(!glm::equal(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr"); static_assert(!glm::equal(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr");
# endif
int Error = 0; int Error = 0;
@ -15,8 +17,10 @@ int test_equal()
int test_notEqual() int test_notEqual()
{ {
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
static_assert(glm::notEqual(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr"); static_assert(glm::notEqual(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr");
static_assert(!glm::notEqual(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr"); static_assert(!glm::notEqual(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr");
# endif
int Error = 0; int Error = 0;

Loading…
Cancel
Save