Fixed defaulted constructor and fixed anonymous struct detection and use

This commit is contained in:
Christophe Riccio 2018-07-23 16:02:21 +02:00
parent ba4a4c6014
commit 508d0bcbb1
15 changed files with 103 additions and 89 deletions

View File

@ -15,7 +15,7 @@ namespace glm
packed_mediump, ///< Typed data is tightly packed in memory and operations are executed with medium precision in term of ULPs for higher performance
packed_lowp, ///< Typed data is tightly packed in memory and operations are executed with low precision in term of ULPs to maximize performance
# if GLM_HAS_ANONYMOUS_STRUCT
# if (GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE)
aligned_highp, ///< Typed data is aligned in memory allowing SIMD optimizations and operations are executed with high precision in term of ULPs
aligned_mediump, ///< Typed data is aligned in memory allowing SIMD optimizations and operations are executed with high precision in term of ULPs for higher performance
aligned_lowp, // ///< Typed data is aligned in memory allowing SIMD optimizations and operations are executed with high precision in term of ULPs to maximize performance
@ -27,7 +27,7 @@ namespace glm
lowp = packed_lowp, ///< By default lowp qualifier is also packed
packed = packed_highp, ///< By default packed qualifier is also high precision
# if GLM_HAS_ANONYMOUS_STRUCT && defined(GLM_FORCE_ALIGNED)
# if (GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE) && defined(GLM_FORCE_DEFAULT_ALIGNED_GENTYPES)
defaultp = aligned_highp
# else
defaultp = highp
@ -47,7 +47,7 @@ namespace detail
static const bool value = false;
};
# if GLM_HAS_ANONYMOUS_STRUCT
# if GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE
template<>
struct is_aligned<glm::aligned_lowp>
{
@ -65,7 +65,7 @@ namespace detail
{
static const bool value = true;
};
# endif//GLM_HAS_ANONYMOUS_STRUCT
# endif
template<length_t L, typename T, bool is_aligned>
struct storage
@ -75,7 +75,7 @@ namespace detail
} type;
};
# if GLM_LANG & GLM_LANG_CXX11_FLAG
# if GLM_HAS_ALIGNOF
template<length_t L, typename T>
struct storage<L, T, true>
{

View File

@ -370,10 +370,6 @@
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14) && (GLM_ARCH & GLM_ARCH_X86_BIT))))
#endif
///////////////////////////////////////////////////////////////////////////////////
#define GLM_HAS_ANONYMOUS_STRUCT (GLM_LANG & GLM_LANG_CXXMS_FLAG)
///////////////////////////////////////////////////////////////////////////////////
// OpenMP
#ifdef _OPENMP
@ -482,7 +478,7 @@
#define GLM_SWIZZLE_OPERATOR 1
#define GLM_SWIZZLE_FUNCTION 2
#if defined(GLM_FORCE_SWIZZLE) && GLM_HAS_ANONYMOUS_STRUCT
#if defined(GLM_FORCE_SWIZZLE) && (GLM_LANG & GLM_LANG_CXXMS_FLAG)
# define GLM_SWIZZLE GLM_SWIZZLE_OPERATOR
#elif defined(GLM_FORCE_SWIZZLE)
# define GLM_SWIZZLE GLM_SWIZZLE_FUNCTION
@ -582,8 +578,10 @@
#endif
#if GLM_HAS_DEFAULTED_FUNCTIONS && !defined(GLM_FORCE_CTOR_INIT)
# define GLM_USE_DEFAULTED_FUNCTIONS GLM_ENABLE
# define GLM_DEFAULT = default
#else
# define GLM_USE_DEFAULTED_FUNCTIONS GLM_DISABLE
# define GLM_DEFAULT
#endif
@ -638,6 +636,24 @@ namespace glm
# error "GLM error: A different version of GLM is already included. Define GLM_FORCE_IGNORE_VERSION before including GLM headers to ignore this error."
#elif GLM_SETUP_INCLUDED == GLM_VERSION
///////////////////////////////////////////////////////////////////////////////////
// Enable aligned gentypes
#if defined(GLM_FORCE_ALIGNED_GENTYPES) && GLM_HAS_ALIGNOF
# define GLM_USE_ALIGNED_GENTYPES GLM_ENABLE
#else
# define GLM_USE_ALIGNED_GENTYPES GLM_DISABLE
#endif
///////////////////////////////////////////////////////////////////////////////////
// Implementation detail
#if (((GLM_LANG & GLM_LANG_CXXMS_FLAG) && (GLM_ARCH & GLM_ARCH_SIMD_BIT)) || (GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR) || (GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE))
# define GLM_USE_ANONYMOUS_STRUCT GLM_ENABLE
#else
# define GLM_USE_ANONYMOUS_STRUCT GLM_DISABLE
#endif
///////////////////////////////////////////////////////////////////////////////////
// Messages

View File

@ -5,21 +5,19 @@ namespace glm
{
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<1, T, Q>::vec()
# ifdef GLM_FORCE_CTOR_INIT
: x(0)
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<1, T, Q>::vec(vec<1, T, Q> const& v)
: x(v.x)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# endif
template<typename T, qualifier Q>
template<qualifier P>
@ -78,12 +76,14 @@ namespace glm
// -- Unary arithmetic operators --
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<1, T, Q> & vec<1, T, Q>::operator=(vec<1, T, Q> const& v)
{
this->x = v.x;
return *this;
}
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<1, T, Q> & vec<1, T, Q>::operator=(vec<1, T, Q> const& v)
{
this->x = v.x;
return *this;
}
# endif
template<typename T, qualifier Q>
template<typename U>

View File

@ -24,7 +24,7 @@ namespace glm
// -- Data --
# if GLM_HAS_ANONYMOUS_STRUCT
# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE
union
{
struct{ T x, y; };
@ -114,7 +114,7 @@ namespace glm
// -- Unary arithmetic operators --
GLM_FUNC_DECL vec<2, T, Q> & operator=(vec const& v);
GLM_FUNC_DECL vec<2, T, Q> & operator=(vec const& v) GLM_DEFAULT;
template<typename U>
GLM_FUNC_DECL vec<2, T, Q> & operator=(vec<2, U, Q> const& v);

View File

@ -7,21 +7,19 @@ namespace glm
{
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<2, T, Q>::vec()
# ifdef GLM_FORCE_CTOR_INIT
: x(0), y(0)
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<2, T, Q>::vec(vec<2, T, Q> const& v)
: x(v.x), y(v.y)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# endif
template<typename T, qualifier Q>
template<qualifier P>
@ -119,13 +117,15 @@ namespace glm
// -- Unary arithmetic operators --
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<2, T, Q> & vec<2, T, Q>::operator=(vec<2, T, Q> const& v)
{
this->x = v.x;
this->y = v.y;
return *this;
}
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<2, T, Q> & vec<2, T, Q>::operator=(vec<2, T, Q> const& v)
{
this->x = v.x;
this->y = v.y;
return *this;
}
# endif
template<typename T, qualifier Q>
template<typename U>

View File

@ -24,7 +24,7 @@ namespace glm
// -- Data --
# if GLM_HAS_ANONYMOUS_STRUCT
# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE
union
{
struct{ T x, y, z; };
@ -81,7 +81,7 @@ namespace glm
template<typename U, qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 explicit vec(vec<1, U, P> const& v);
/// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template<typename X, typename Y, typename Z>
GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 vec(X x, Y y, Z z);
template<typename X, typename Y, typename Z>
@ -144,7 +144,7 @@ namespace glm
// -- Unary arithmetic operators --
GLM_FUNC_DECL vec<3, T, Q>& operator=(vec<3, T, Q> const& v);
GLM_FUNC_DECL vec<3, T, Q>& operator=(vec<3, T, Q> const& v) GLM_DEFAULT;
template<typename U>
GLM_FUNC_DECL vec<3, T, Q> & operator=(vec<3, U, Q> const& v);

View File

@ -5,21 +5,19 @@ namespace glm
{
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<3, T, Q>::vec()
# ifdef GLM_FORCE_CTOR_INIT
: x(0), y(0), z(0)
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<3, T, Q>::vec(vec<3, T, Q> const& v)
: x(v.x), y(v.y), z(v.z)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# endif
template<typename T, qualifier Q>
template<qualifier P>
@ -181,14 +179,16 @@ namespace glm
// -- Unary arithmetic operators --
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<3, T, Q>& vec<3, T, Q>::operator=(vec<3, T, Q> const& v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
return *this;
}
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<3, T, Q>& vec<3, T, Q>::operator=(vec<3, T, Q> const& v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
return *this;
}
# endif
template<typename T, qualifier Q>
template<typename U>

View File

@ -24,7 +24,7 @@ namespace glm
// -- Data --
# if GLM_HAS_ANONYMOUS_STRUCT
# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE
union
{
struct { T x, y, z, w; };
@ -219,7 +219,7 @@ namespace glm
// -- Unary arithmetic operators --
GLM_FUNC_DECL vec<4, T, Q>& operator=(vec<4, T, Q> const& v);
GLM_FUNC_DECL vec<4, T, Q>& operator=(vec<4, T, Q> const& v) GLM_DEFAULT;
template<typename U>
GLM_FUNC_DECL vec<4, T, Q>& operator=(vec<4, U, Q> const& v);

View File

@ -158,21 +158,19 @@ namespace detail
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<4, T, Q>::vec()
# ifdef GLM_FORCE_CTOR_INIT
: x(0), y(0), z(0), w(0)
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 vec<4, T, Q>::vec(vec<4, T, Q> const& v)
: x(v.x), y(v.y), z(v.z), w(v.w)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# endif
template<typename T, qualifier Q>
template<qualifier P>
@ -520,15 +518,17 @@ namespace detail
// -- Unary arithmetic operators --
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<4, T, Q>& vec<4, T, Q>::operator=(vec<4, T, Q> const& v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
this->w = v.w;
return *this;
}
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<4, T, Q>& vec<4, T, Q>::operator=(vec<4, T, Q> const& v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
this->w = v.w;
return *this;
}
# endif
template<typename T, qualifier Q>
template<typename U>

View File

@ -41,7 +41,7 @@ namespace glm
// -- Data --
# if GLM_HAS_ANONYMOUS_STRUCT
# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE
union
{
T x;
@ -120,7 +120,7 @@ namespace glm
*/
// -- Unary arithmetic operators --
GLM_FUNC_DECL vec<1, T, Q> & operator=(vec const& v);
GLM_FUNC_DECL vec<1, T, Q> & operator=(vec const& v) GLM_DEFAULT;
template<typename U>
GLM_FUNC_DECL vec<1, T, Q> & operator=(vec<1, U, Q> const& v);

View File

@ -84,21 +84,19 @@ namespace detail
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 tquat<T, Q>::tquat()
# ifdef GLM_FORCE_CTOR_INIT
: x(0), y(0), z(0), w(1)
# endif
{}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 tquat<T, Q>::tquat(tquat<T, Q> const& q)
: x(q.x), y(q.y), z(q.z), w(q.w)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# endif
template<typename T, qualifier Q>
template<qualifier P>
@ -223,7 +221,7 @@ namespace detail
// -- Unary arithmetic operators --
# if !GLM_HAS_DEFAULTED_FUNCTIONS
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER tquat<T, Q> & tquat<T, Q>::operator=(tquat<T, Q> const& q)
{
@ -233,7 +231,7 @@ namespace detail
this->z = q.z;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# endif
template<typename T, qualifier Q>
template<typename U>

View File

@ -12,9 +12,10 @@
#pragma once
#if !GLM_HAS_ANONYMOUS_STRUCT
# error "GLM: Aligned types are not supported on this platform"
#if !GLM_USE_ANONYMOUS_STRUCT
# error "GLM: Aligned gentypes require to enable C++ language extensions and to define GLM_FORCE_ALIGNED_GENTYPES before including GLM headers."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTC_type_aligned extension included")
#endif

View File

@ -24,7 +24,7 @@ namespace glm
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX11 tdualquat<T, Q>::tdualquat()
# ifdef GLM_FORCE_CTOR_INIT
@ -32,15 +32,13 @@ namespace glm
, dual(tquat<T, Q>(0, 0, 0, 0))
# endif
{}
# endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 tdualquat<T, Q>::tdualquat(tdualquat<T, Q> const& d)
: real(d.real)
, dual(d.dual)
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# endif
template<typename T, qualifier Q>
template<qualifier P>
@ -93,7 +91,7 @@ namespace glm
// -- Unary arithmetic operators --
# if !GLM_HAS_DEFAULTED_FUNCTIONS
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER tdualquat<T, Q> & tdualquat<T, Q>::operator=(tdualquat<T, Q> const& q)
{
@ -101,7 +99,7 @@ namespace glm
this->dual = q.dual;
return *this;
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
# endif
template<typename T, qualifier Q>
template<typename U>

View File

@ -6,7 +6,7 @@ static int test_vec1_ctor()
{
int Error = 0;
# if GLM_HAS_DEFAULTED_FUNCTIONS
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
{
union pack
{
@ -20,7 +20,7 @@ static int test_vec1_ctor()
B.f = glm::vec1(1);
Error += glm::all(glm::equal(B.i, glm::ivec1(1065353216))) ? 0 : 1;
}
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
# endif//GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
return Error;
}
@ -29,7 +29,7 @@ static int test_vec2_ctor()
{
int Error = 0;
# if GLM_HAS_DEFAULTED_FUNCTIONS
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
{
union pack
{
@ -43,7 +43,7 @@ static int test_vec2_ctor()
B.f = glm::vec2(1);
Error += glm::all(glm::equal(B.i, glm::ivec2(1065353216))) ? 0 : 1;
}
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
# endif
return Error;
}
@ -52,7 +52,7 @@ static int test_vec3_ctor()
{
int Error = 0;
# if GLM_HAS_DEFAULTED_FUNCTIONS
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
{
union pack
{
@ -66,7 +66,7 @@ static int test_vec3_ctor()
B.f = glm::vec3(1);
Error += glm::all(glm::equal(B.i, glm::ivec3(1065353216))) ? 0 : 1;
}
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
# endif
return Error;
}
@ -75,7 +75,7 @@ static int test_vec4_ctor()
{
int Error = 0;
# if GLM_HAS_DEFAULTED_FUNCTIONS
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
{
union pack
{
@ -89,7 +89,7 @@ static int test_vec4_ctor()
B.f = glm::vec4(1);
Error += glm::all(glm::equal(B.i, glm::ivec4(1065353216))) ? 0 : 1;
}
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
# endif
return Error;
}

View File

@ -1,7 +1,8 @@
#define GLM_FORCE_MESSAGES
#define GLM_FORCE_ALIGNED_GENTYPES
#include <glm/glm.hpp>
#if GLM_HAS_ANONYMOUS_STRUCT
#if GLM_USE_ALIGNED_GENTYPES == GLM_ENABLE
#include <glm/gtc/type_aligned.hpp>
GLM_STATIC_ASSERT(glm::detail::is_aligned<glm::aligned_lowp>::value, "aligned_lowp is not aligned");
@ -143,4 +144,4 @@ int main()
return 0;
}
#endif//GLM_HAS_ANONYMOUS_STRUCT
#endif//GLM_USE_ANONYMOUS_STRUCT