diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index efac4987..02397973 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -619,7 +619,8 @@ #else # define GLM_HAS_DEFAULTED_FUNCTIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \ + ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12))) #endif // N2118 @@ -923,6 +924,12 @@ # define GLM_RESTRICT_VAR #endif//GLM_COMPILER +#if GLM_HAS_DEFAULTED_FUNCTIONS +# define GLM_DEFAULT = default +#else +# define GLM_DEFAULT +#endif + #if GLM_HAS_CONSTEXPR # define GLM_CONSTEXPR constexpr # define GLM_RELAXED_CONSTEXPR constexpr diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index aef5922d..36f15ff0 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -112,8 +112,8 @@ namespace glm ////////////////////////////////////// // Implicit basic constructors - GLM_FUNC_DECL tvec1(); - GLM_FUNC_DECL tvec1(tvec1 const & v); + GLM_FUNC_DECL tvec1() GLM_DEFAULT; + GLM_FUNC_DECL tvec1(tvec1 const & v) GLM_DEFAULT; template GLM_FUNC_DECL tvec1(tvec1 const & v); @@ -154,7 +154,7 @@ namespace glm ////////////////////////////////////// // Unary arithmetic operators - GLM_FUNC_DECL tvec1 & operator=(tvec1 const & v); + GLM_FUNC_DECL tvec1 & operator=(tvec1 const & v) GLM_DEFAULT; template GLM_FUNC_DECL tvec1 & operator=(tvec1 const & v); diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index bd756cd4..887e9ab3 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -35,17 +35,19 @@ namespace glm ////////////////////////////////////// // Implicit basic constructors - template - GLM_FUNC_QUALIFIER tvec1::tvec1() -# ifndef GLM_FORCE_NO_CTOR_INIT - : x(0) -# endif - {} +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template + GLM_FUNC_QUALIFIER tvec1::tvec1() +# ifndef GLM_FORCE_NO_CTOR_INIT + : x(0) +# endif + {} - template - GLM_FUNC_QUALIFIER tvec1::tvec1(tvec1 const & v) - : x(v.x) - {} + template + GLM_FUNC_QUALIFIER tvec1::tvec1(tvec1 const & v) + : x(v.x) + {} +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template template @@ -140,12 +142,14 @@ namespace glm ////////////////////////////////////// // Unary arithmetic operators - template - GLM_FUNC_QUALIFIER tvec1 & tvec1::operator=(tvec1 const & v) - { - this->x = v.x; - return *this; - } +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template + GLM_FUNC_QUALIFIER tvec1 & tvec1::operator=(tvec1 const & v) + { + this->x = v.x; + return *this; + } +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template template diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 3609a24f..62f9ac19 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -113,8 +113,8 @@ namespace glm ////////////////////////////////////// // Implicit basic constructors - GLM_FUNC_DECL tvec2(); - GLM_FUNC_DECL tvec2(tvec2 const & v); + GLM_FUNC_DECL tvec2() GLM_DEFAULT; + GLM_FUNC_DECL tvec2(tvec2 const & v) GLM_DEFAULT; template GLM_FUNC_DECL tvec2(tvec2 const & v); @@ -162,7 +162,7 @@ namespace glm ////////////////////////////////////// // Unary arithmetic operators - GLM_FUNC_DECL tvec2& operator=(tvec2 const & v); + GLM_FUNC_DECL tvec2& operator=(tvec2 const & v) GLM_DEFAULT; template GLM_FUNC_DECL tvec2& operator=(tvec2 const & v); diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 4db29479..5458e54a 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -28,51 +28,22 @@ namespace glm { -#ifdef GLM_FORCE_SIZE_FUNC - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec2::size() const - { - return 2; - } -#else - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec2::length() const - { - return 2; - } -#endif - - ////////////////////////////////////// - // Accesses - - template - GLM_FUNC_QUALIFIER T & tvec2::operator[](length_t i) - { - assert(i >= 0 && static_cast(i) < detail::component_count(*this)); - return (&x)[i]; - } - - template - GLM_FUNC_QUALIFIER T const & tvec2::operator[](length_t i) const - { - assert(i >= 0 && static_cast(i) < detail::component_count(*this)); - return (&x)[i]; - } - ////////////////////////////////////// // Implicit basic constructors - template - GLM_FUNC_QUALIFIER tvec2::tvec2() -# ifndef GLM_FORCE_NO_CTOR_INIT - : x(0), y(0) -# endif - {} +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template + GLM_FUNC_QUALIFIER tvec2::tvec2() +# ifndef GLM_FORCE_NO_CTOR_INIT + : x(0), y(0) +# endif + {} - template - GLM_FUNC_QUALIFIER tvec2::tvec2(tvec2 const & v) - : x(v.x), y(v.y) - {} + template + GLM_FUNC_QUALIFIER tvec2::tvec2(tvec2 const & v) + : x(v.x), y(v.y) + {} +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template template @@ -138,16 +109,63 @@ namespace glm , y(static_cast(v.y)) {} + ////////////////////////////////////// + // Component accesses + +# ifdef GLM_FORCE_SIZE_FUNC + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2::size_type tvec2::size() const + { + return 2; + } + + template + GLM_FUNC_QUALIFIER T & tvec2::operator[](typename tvec2::size_type i) + { + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); + return (&x)[i]; + } + + template + GLM_FUNC_QUALIFIER T const & tvec2::operator[](typename tvec2::size_type i) const + { + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); + return (&x)[i]; + } +# else + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2::length_type tvec2::length() const + { + return 2; + } + + template + GLM_FUNC_QUALIFIER T & tvec2::operator[](typename tvec2::length_type i) + { + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); + return (&x)[i]; + } + + template + GLM_FUNC_QUALIFIER T const & tvec2::operator[](typename tvec2::length_type i) const + { + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); + return (&x)[i]; + } +# endif//GLM_FORCE_SIZE_FUNC + ////////////////////////////////////// // Unary arithmetic operators - template - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator=(tvec2 const & v) - { - this->x = v.x; - this->y = v.y; - return *this; - } +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator=(tvec2 const & v) + { + this->x = v.x; + this->y = v.y; + return *this; + } +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template template diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 9665c55f..c74fde18 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -114,8 +114,8 @@ namespace glm ////////////////////////////////////// // Implicit basic constructors - GLM_FUNC_DECL tvec3(); - GLM_FUNC_DECL tvec3(tvec3 const & v); + GLM_FUNC_DECL tvec3() GLM_DEFAULT; + GLM_FUNC_DECL tvec3(tvec3 const & v) GLM_DEFAULT; template GLM_FUNC_DECL tvec3(tvec3 const & v); @@ -184,7 +184,7 @@ namespace glm ////////////////////////////////////// // Unary arithmetic operators - GLM_FUNC_DECL tvec3 & operator=(tvec3 const & v); + GLM_FUNC_DECL tvec3 & operator=(tvec3 const & v) GLM_DEFAULT; template GLM_FUNC_DECL tvec3 & operator=(tvec3 const & v); diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index b2088d8b..a032cd3f 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -35,17 +35,19 @@ namespace glm ////////////////////////////////////// // Implicit basic constructors - template - GLM_FUNC_QUALIFIER tvec3::tvec3() -# ifndef GLM_FORCE_NO_CTOR_INIT - : x(0), y(0), z(0) -# endif - {} +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template + GLM_FUNC_QUALIFIER tvec3::tvec3() +# ifndef GLM_FORCE_NO_CTOR_INIT + : x(0), y(0), z(0) +# endif + {} - template - GLM_FUNC_QUALIFIER tvec3::tvec3(tvec3 const & v) - : x(v.x), y(v.y), z(v.z) - {} + template + GLM_FUNC_QUALIFIER tvec3::tvec3(tvec3 const & v) + : x(v.x), y(v.y), z(v.z) + {} +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template template @@ -188,14 +190,16 @@ namespace glm ////////////////////////////////////// // Unary arithmetic operators - template - GLM_FUNC_QUALIFIER tvec3& tvec3::operator=(tvec3 const & v) - { - this->x = v.x; - this->y = v.y; - this->z = v.z; - return *this; - } +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template + GLM_FUNC_QUALIFIER tvec3& tvec3::operator=(tvec3 const & v) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + return *this; + } +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template template diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index b48040fd..fb6a6760 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -171,8 +171,8 @@ namespace detail ////////////////////////////////////// // Implicit basic constructors - GLM_FUNC_DECL tvec4(); - GLM_FUNC_DECL tvec4(tvec4 const & v); + GLM_FUNC_DECL tvec4() GLM_DEFAULT; + GLM_FUNC_DECL tvec4(tvec4 const & v) GLM_DEFAULT; template GLM_FUNC_DECL tvec4(tvec4 const & v); @@ -182,7 +182,6 @@ namespace detail GLM_FUNC_DECL explicit tvec4(ctor); GLM_FUNC_DECL explicit tvec4(T s); GLM_FUNC_DECL tvec4(T a, T b, T c, T d); - GLM_FUNC_DECL ~tvec4(){} ////////////////////////////////////// // Conversion scalar constructors @@ -284,7 +283,7 @@ namespace detail ////////////////////////////////////// // Unary arithmetic operators - GLM_FUNC_DECL tvec4 & operator=(tvec4 const & v); + GLM_FUNC_DECL tvec4 & operator=(tvec4 const & v) GLM_DEFAULT; template GLM_FUNC_DECL tvec4 & operator=(tvec4 const & v); diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index fbdf51fc..35869cb7 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -35,17 +35,19 @@ namespace glm ////////////////////////////////////// // Implicit basic constructors - template - GLM_FUNC_QUALIFIER tvec4::tvec4() -# ifndef GLM_FORCE_NO_CTOR_INIT - : x(0), y(0), z(0), w(0) -# endif - {} +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template + GLM_FUNC_QUALIFIER tvec4::tvec4() +# ifndef GLM_FORCE_NO_CTOR_INIT + : x(0), y(0), z(0), w(0) +# endif + {} - template - GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) - : x(v.x), y(v.y), z(v.z), w(v.w) - {} + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) + : x(v.x), y(v.y), z(v.z), w(v.w) + {} +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template template @@ -250,15 +252,17 @@ namespace glm ////////////////////////////////////// // Unary arithmetic operators - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator=(tvec4 const & v) - { - this->x = v.x; - this->y = v.y; - this->z = v.z; - this->w = v.w; - return *this; - } +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator=(tvec4 const & v) + { + this->x = v.x; + this->y = v.y; + this->z = v.z; + this->w = v.w; + return *this; + } +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template template diff --git a/glm/detail/type_vec4_sse2.inl b/glm/detail/type_vec4_sse2.inl index 002446f2..623db81a 100644 --- a/glm/detail/type_vec4_sse2.inl +++ b/glm/detail/type_vec4_sse2.inl @@ -31,24 +31,22 @@ /////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace detail -{ -}//namespace detail - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4() -# ifndef GLM_FORCE_NO_CTOR_INIT - : data(_mm_setzero_ps()) -# endif - {} +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template <> + GLM_FUNC_QUALIFIER tvec4::tvec4() +# ifndef GLM_FORCE_NO_CTOR_INIT + : data(_mm_setzero_ps()) +# endif + {} - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4() -# ifndef GLM_FORCE_NO_CTOR_INIT - : data(_mm_setzero_ps()) -# endif - {} + template <> + GLM_FUNC_QUALIFIER tvec4::tvec4() +# ifndef GLM_FORCE_NO_CTOR_INIT + : data(_mm_setzero_ps()) +# endif + {} +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS template <> GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index 67917844..f648e9d2 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -69,6 +69,22 @@ int test_vec1_ctor() { int Error = 0; +# if GLM_HAS_DEFAULTED_FUNCTIONS + { + union pack + { + glm::vec1 f; + glm::ivec1 i; + } A, B; + + A.f = glm::vec1(0); + Error += glm::all(glm::equal(A.i, glm::ivec1(0))) ? 0 : 1; + + B.f = glm::vec1(1); + Error += glm::all(glm::equal(B.i, glm::ivec1(1065353216))) ? 0 : 1; + } +# endif//GLM_HAS_DEFAULTED_FUNCTIONS + # if GLM_HAS_TRIVIAL_QUERIES // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1; diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 2b8f8575..2701d7a6 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -229,6 +229,22 @@ int test_vec2_ctor() { int Error = 0; +# if GLM_HAS_DEFAULTED_FUNCTIONS + { + union pack + { + glm::vec2 f; + glm::ivec2 i; + } A, B; + + A.f = glm::vec2(0); + Error += glm::all(glm::equal(A.i, glm::ivec2(0))) ? 0 : 1; + + B.f = glm::vec2(1); + Error += glm::all(glm::equal(B.i, glm::ivec2(1065353216))) ? 0 : 1; + } +# endif//GLM_HAS_DEFAULTED_FUNCTIONS + # if GLM_HAS_TRIVIAL_QUERIES // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1; diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index e2ce6ee1..025253d5 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -45,6 +45,22 @@ int test_vec3_ctor() { int Error = 0; +# if GLM_HAS_DEFAULTED_FUNCTIONS + { + union pack + { + glm::vec3 f; + glm::ivec3 i; + } A, B; + + A.f = glm::vec3(0); + Error += glm::all(glm::equal(A.i, glm::ivec3(0))) ? 0 : 1; + + B.f = glm::vec3(1); + Error += glm::all(glm::equal(B.i, glm::ivec3(1065353216))) ? 0 : 1; + } +# endif//GLM_HAS_DEFAULTED_FUNCTIONS + # if GLM_HAS_TRIVIAL_QUERIES // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1; diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index 4c80f5ba..2a3adfd9 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -68,6 +68,22 @@ int test_vec4_ctor() { int Error = 0; +# if GLM_HAS_DEFAULTED_FUNCTIONS + { + union pack + { + glm::vec4 f; + glm::ivec4 i; + } A, B; + + A.f = glm::vec4(0); + Error += glm::all(glm::equal(A.i, glm::ivec4(0))) ? 0 : 1; + + B.f = glm::vec4(1); + Error += glm::all(glm::equal(B.i, glm::ivec4(1065353216))) ? 0 : 1; + } +# endif//GLM_HAS_DEFAULTED_FUNCTIONS + { glm::ivec4 A(1, 2, 3, 4); glm::ivec4 B(A);