Fixed Visual C++ constexpr build error #555, #556

This commit is contained in:
Christophe Riccio 2016-10-10 22:03:57 +02:00
parent cae9f61e46
commit 19a6d64e8c
7 changed files with 53 additions and 43 deletions

View File

@ -713,7 +713,11 @@
#if GLM_HAS_CONSTEXPR
# define GLM_CONSTEXPR constexpr
//# if GLM_ARCH == GLM_ARCH_PURE
# define GLM_CONSTEXPR_CTOR constexpr
//# else
//# define GLM_CONSTEXPR_CTOR
//# endif
# define GLM_RELAXED_CONSTEXPR constexpr
#elif GLM_HAS_CONSTEXPR_PARTIAL
# define GLM_CONSTEXPR constexpr
@ -725,12 +729,6 @@
# define GLM_RELAXED_CONSTEXPR const
#endif
#if GLM_ARCH == GLM_ARCH_PURE
# define GLM_CONSTEXPR_SIMD GLM_CONSTEXPR
#else
# define GLM_CONSTEXPR_SIMD
#endif
#ifdef GLM_FORCE_EXPLICIT_CTOR
# define GLM_EXPLICIT explicit
#else

View File

@ -86,24 +86,24 @@ namespace glm
// -- Implicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR tvec4() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec4<T, P> const& v) GLM_DEFAULT;
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR tvec4() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR tvec4(tvec4<T, P> const& v) GLM_DEFAULT;
template <precision Q>
GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec4<T, Q> const& v);
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR tvec4(tvec4<T, Q> const& v);
// -- Explicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit tvec4(ctor);
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD explicit tvec4(T scalar);
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD tvec4(T a, T b, T c, T d);
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit tvec4(T scalar);
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR tvec4(T a, T b, T c, T d);
// -- Conversion scalar constructors --
/// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, typename D>
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD tvec4(A a, B b, C c, D d);
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR tvec4(A a, B b, C c, D d);
template <typename A, typename B, typename C, typename D>
GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec1<A, P> const& a, tvec1<B, P> const& b, tvec1<C, P> const& c, tvec1<D, P> const& d);
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR tvec4(tvec1<A, P> const& a, tvec1<B, P> const& b, tvec1<C, P> const& c, tvec1<D, P> const& d);
// -- Conversion vector constructors --

View File

@ -156,7 +156,7 @@ namespace detail
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec4<T, P>::tvec4()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(0)
# endif
@ -165,14 +165,14 @@ namespace detail
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec4<T, P>::tvec4(tvec4<T, P> const & v)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec4<T, P> const & v)
: x(v.x), y(v.y), z(v.z), w(v.w)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec4<T, P>::tvec4(tvec4<T, Q> const & v)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec4<T, Q> const & v)
: x(v.x), y(v.y), z(v.z), w(v.w)
{}
@ -183,12 +183,12 @@ namespace detail
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(T scalar)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(T scalar)
: x(scalar), y(scalar), z(scalar), w(scalar)
{}
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(T a, T b, T c, T d)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(T a, T b, T c, T d)
: x(a), y(b), z(c), w(d)
{}
@ -196,7 +196,7 @@ namespace detail
template <typename T, precision P>
template <typename A, typename B, typename C, typename D>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(A a, B b, C c, D d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(A a, B b, C c, D d) :
x(static_cast<T>(a)),
y(static_cast<T>(b)),
z(static_cast<T>(c)),
@ -205,7 +205,7 @@ namespace detail
template <typename T, precision P>
template <typename A, typename B, typename C, typename D>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tvec4<T, P>::tvec4(tvec1<A, P> const & a, tvec1<B, P> const & b, tvec1<C, P> const & c, tvec1<D, P> const & d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec1<A, P> const & a, tvec1<B, P> const & b, tvec1<C, P> const & c, tvec1<D, P> const & d) :
x(static_cast<T>(a.x)),
y(static_cast<T>(b.x)),
z(static_cast<T>(c.x)),

View File

@ -363,117 +363,117 @@ namespace detail
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_lowp>::tvec4(float s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_lowp>::tvec4(float s) :
data(_mm_set1_ps(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_mediump>::tvec4(float s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_mediump>::tvec4(float s) :
data(_mm_set1_ps(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_highp>::tvec4(float s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_highp>::tvec4(float s) :
data(_mm_set1_ps(s))
{}
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<double, aligned_lowp>::tvec4(double s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<double, aligned_lowp>::tvec4(double s) :
data(_mm256_set1_pd(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<double, aligned_mediump>::tvec4(double s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<double, aligned_mediump>::tvec4(double s) :
data(_mm256_set1_pd(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<double, aligned_highp>::tvec4(double s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<double, aligned_highp>::tvec4(double s) :
data(_mm256_set1_pd(s))
{}
# endif
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_lowp>::tvec4(int32 s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int32, aligned_lowp>::tvec4(int32 s) :
data(_mm_set1_epi32(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_mediump>::tvec4(int32 s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int32, aligned_mediump>::tvec4(int32 s) :
data(_mm_set1_epi32(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_highp>::tvec4(int32 s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int32, aligned_highp>::tvec4(int32 s) :
data(_mm_set1_epi32(s))
{}
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int64, aligned_lowp>::tvec4(int64 s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int64, aligned_lowp>::tvec4(int64 s) :
data(_mm256_set1_epi64x(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int64, aligned_mediump>::tvec4(int64 s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int64, aligned_mediump>::tvec4(int64 s) :
data(_mm256_set1_epi64x(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int64, aligned_highp>::tvec4(int64 s) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int64, aligned_highp>::tvec4(int64 s) :
data(_mm256_set1_epi64x(s))
{}
# endif
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_lowp>::tvec4(float a, float b, float c, float d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_lowp>::tvec4(float a, float b, float c, float d) :
data(_mm_set_ps(d, c, b, a))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_mediump>::tvec4(float a, float b, float c, float d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_mediump>::tvec4(float a, float b, float c, float d) :
data(_mm_set_ps(d, c, b, a))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_highp>::tvec4(float a, float b, float c, float d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_highp>::tvec4(float a, float b, float c, float d) :
data(_mm_set_ps(d, c, b, a))
{}
template <>
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_lowp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int32, aligned_lowp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
data(_mm_set_epi32(d, c, b, a))
{}
template <>
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_mediump>::tvec4(int32 a, int32 b, int32 c, int32 d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int32, aligned_mediump>::tvec4(int32 a, int32 b, int32 c, int32 d) :
data(_mm_set_epi32(d, c, b, a))
{}
template <>
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_highp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<int32, aligned_highp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
data(_mm_set_epi32(d, c, b, a))
{}
template <>
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_lowp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_lowp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
data(_mm_castsi128_ps(_mm_set_epi32(d, c, b, a)))
{}
template <>
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_mediump>::tvec4(int32 a, int32 b, int32 c, int32 d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_mediump>::tvec4(int32 a, int32 b, int32 c, int32 d) :
data(_mm_castsi128_ps(_mm_set_epi32(d, c, b, a)))
{}
template <>
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_highp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<float, aligned_highp>::tvec4(int32 a, int32 b, int32 c, int32 d) :
data(_mm_castsi128_ps(_mm_set_epi32(d, c, b, a)))
{}
}//namespace glm

View File

@ -53,7 +53,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
#### [GLM 0.9.8.2](https://github.com/g-truc/glm/tree/0.9.8) - 2016-09-25
##### Fixes:
- Fixed Visual C++ constexpr build error #555, #556
#### [GLM 0.9.8.1](https://github.com/g-truc/glm/releases/tag/0.9.8.1) - 2016-09-25
##### Improvements:

View File

@ -1,4 +1,5 @@
glmCreateTestGTC(core_force_pure)
glmCreateTestGTC(core_force_unrestricted_gentype)
glmCreateTestGTC(core_type_aligned)
glmCreateTestGTC(core_type_cast)
glmCreateTestGTC(core_type_ctor)

View File

@ -0,0 +1,11 @@
#define GLM_FORCE_UNRESTRICTED_GENTYPE
#include <glm/glm.hpp>
int main()
{
int Error = 0;
return Error;
}