From d3b8b2b64e94e41afdef6560a1caaffc8076b6ce Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 14 Jan 2014 22:51:04 +0100 Subject: [PATCH] Added move contructors and assignment operators (#141) --- glm/detail/setup.hpp | 19 +++++++++ glm/detail/type_mat2x2.hpp | 38 ++++++++++++++---- glm/detail/type_mat2x2.inl | 17 ++------ glm/detail/type_mat2x3.hpp | 34 +++++++++++++--- glm/detail/type_mat2x4.hpp | 34 +++++++++++++--- glm/detail/type_mat3x2.hpp | 36 ++++++++++++++--- glm/detail/type_mat3x3.hpp | 36 ++++++++++++++--- glm/detail/type_mat3x4.hpp | 36 ++++++++++++++--- glm/detail/type_mat4x2.hpp | 38 +++++++++++++++--- glm/detail/type_mat4x3.hpp | 38 +++++++++++++++--- glm/detail/type_mat4x4.hpp | 38 ++++++++++++++---- glm/detail/type_vec1.hpp | 10 ++--- glm/detail/type_vec1.inl | 6 +-- glm/detail/type_vec2.hpp | 20 +++++----- glm/detail/type_vec2.inl | 8 ++-- glm/detail/type_vec3.hpp | 44 ++++++++++----------- glm/detail/type_vec3.inl | 10 ++--- glm/detail/type_vec4.hpp | 79 +++++++++++++++++++------------------- glm/detail/type_vec4.inl | 12 +++--- readme.txt | 1 + 20 files changed, 396 insertions(+), 158 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index a2f50196..1ad465ef 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -527,6 +527,25 @@ ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \ __has_feature(cxx_unrestricted_unions)) +// N2346 +#define GLM_HAS_DEFAULTED_FUNCTIONS ( \ + (GLM_LANG & GLM_LANG_CXX11_FLAG) || \ + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12))) || \ + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \ + __has_feature(cxx_defaulted_functions)) + +// N2118 +#define GLM_HAS_RVALUE_REFERENCES ( \ + (GLM_LANG & GLM_LANG_CXX11_FLAG) || \ + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC11))) || \ + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \ + __has_feature(cxx_rvalue_references)) + +#define GLM_HAS_STL_ARRAY ( \ + (GLM_LANG & GLM_LANG_CXX11_FLAG) || \ + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC10))) || \ + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43))) + // OpenMP #ifdef _OPENMP # if(GLM_COMPILER & GLM_COMPILER_GCC) diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index 8175b777..73dd08d8 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -33,6 +33,14 @@ #include "type_vec2.hpp" #include "type_mat.hpp" #include +#if GLM_HAS_INITIALIZER_LISTS +# include +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif +#include +#include namespace glm{ namespace detail @@ -79,12 +87,20 @@ namespace detail col_type const & v1, col_type const & v2); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat2x2(std::initializer_list m); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat2x2(std::initializer_list l); + + GLM_FUNC_DECL tmat2x2(std::initializer_list > l); +# endif//GLM_HAS_INITIALIZER_LISTS - GLM_FUNC_DECL tmat2x2(std::initializer_list > m); -#endif//GLM_HAS_INITIALIZER_LISTS +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x2(tmat2x2 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -119,6 +135,15 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](length_t i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x2 & operator=(tmat2x2 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x2 & operator=(tmat2x2 const & m); template GLM_FUNC_DECL tmat2x2 & operator=(tmat2x2 const & m); @@ -148,9 +173,6 @@ namespace detail GLM_FUNC_DECL tmat2x2 operator--(int); }; - template - GLM_FUNC_DECL tmat2x2 compute_inverse_mat2(tmat2x2 const & m); - // Binary operators template GLM_FUNC_DECL tmat2x2 operator+ ( diff --git a/glm/detail/type_mat2x2.inl b/glm/detail/type_mat2x2.inl index 85e79baa..55c65437 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -30,31 +30,20 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x2::length() const - { - return 2; - } + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x2::length() const {return 2;} ////////////////////////////////////// // Accesses template - GLM_FUNC_QUALIFIER typename tmat2x2::col_type & - tmat2x2::operator[] - ( - length_t i - ) + GLM_FUNC_QUALIFIER typename tmat2x2::col_type & tmat2x2::operator[](length_t i) { assert(i < this->length()); return this->value[i]; } template - GLM_FUNC_QUALIFIER typename tmat2x2::col_type const & - tmat2x2::operator[] - ( - length_t i - ) const + GLM_FUNC_QUALIFIER typename tmat2x2::col_type const & tmat2x2::operator[](length_t i) const { assert(i < this->length()); return this->value[i]; diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index 0b65376b..af5f1974 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -33,7 +33,14 @@ #include "type_vec2.hpp" #include "type_vec3.hpp" #include "type_mat.hpp" +#if GLM_HAS_INITIALIZER_LISTS +# include +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif #include +#include namespace glm{ namespace detail @@ -73,12 +80,20 @@ namespace detail col_type const & v0, col_type const & v1); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat2x3(std::initializer_list m); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat2x3(std::initializer_list m); - GLM_FUNC_DECL tmat2x3(std::initializer_list > m); -#endif//GLM_HAS_INITIALIZER_LISTS + GLM_FUNC_DECL tmat2x3(std::initializer_list > m); +# endif//GLM_HAS_INITIALIZER_LISTS + +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x3(tmat2x3 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -111,6 +126,15 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](length_t i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x3 & operator=(tmat2x3 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x3 & operator= (tmat2x3 const & m); template GLM_FUNC_DECL tmat2x3 & operator= (tmat2x3 const & m); diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index a2be70b8..bc5442aa 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -33,7 +33,14 @@ #include "type_vec2.hpp" #include "type_vec4.hpp" #include "type_mat.hpp" +#if GLM_HAS_INITIALIZER_LISTS +# include +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif #include +#include namespace glm{ namespace detail @@ -73,12 +80,20 @@ namespace detail col_type const & v0, col_type const & v1); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat2x4(std::initializer_list m); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat2x4(std::initializer_list m); - GLM_FUNC_DECL tmat2x4(std::initializer_list > m); -#endif//GLM_HAS_INITIALIZER_LISTS + GLM_FUNC_DECL tmat2x4(std::initializer_list > m); +# endif//GLM_HAS_INITIALIZER_LISTS + +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x4(tmat2x4 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -113,6 +128,15 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](length_t i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x4 & operator=(tmat2x4 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat2x4& operator= (tmat2x4 const & m); template GLM_FUNC_DECL tmat2x4& operator= (tmat2x4 const & m); diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index 99b3a8e3..2be3555b 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -33,7 +33,14 @@ #include "type_vec2.hpp" #include "type_vec3.hpp" #include "type_mat.hpp" +#if GLM_HAS_INITIALIZER_LISTS +# include +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif #include +#include namespace glm{ namespace detail @@ -75,12 +82,21 @@ namespace detail col_type const & v1, col_type const & v2); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat3x2(std::initializer_list l); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat3x2(std::initializer_list l); - GLM_FUNC_DECL tmat3x2(std::initializer_list > l); -#endif//GLM_HAS_INITIALIZER_LISTS + GLM_FUNC_DECL tmat3x2(std::initializer_list > l); +# endif//GLM_HAS_INITIALIZER_LISTS + +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x2(tmat3x2 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -117,6 +133,16 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](length_t i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x2 & operator=(tmat3x2 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x2 & operator= (tmat3x2 const & m); template GLM_FUNC_DECL tmat3x2 & operator= (tmat3x2 const & m); diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index c7208251..45c40480 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -32,7 +32,14 @@ #include "../fwd.hpp" #include "type_vec3.hpp" #include "type_mat.hpp" +#if GLM_HAS_INITIALIZER_LISTS +# include +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif #include +#include namespace glm{ namespace detail @@ -80,12 +87,21 @@ namespace detail col_type const & v1, col_type const & v2); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat3x3(std::initializer_list m); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat3x3(std::initializer_list m); - GLM_FUNC_DECL tmat3x3(std::initializer_list > m); -#endif//GLM_HAS_INITIALIZER_LISTS + GLM_FUNC_DECL tmat3x3(std::initializer_list > m); +# endif//GLM_HAS_INITIALIZER_LISTS + +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x3(tmat3x3 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -122,6 +138,16 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](length_t i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x3 & operator=(tmat3x3 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x3& operator= (tmat3x3 const & m); template GLM_FUNC_DECL tmat3x3& operator= (tmat3x3 const & m); diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index 4efaf5fd..90da0b18 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -33,7 +33,14 @@ #include "type_vec3.hpp" #include "type_vec4.hpp" #include "type_mat.hpp" +#if GLM_HAS_INITIALIZER_LISTS +# include +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif #include +#include namespace glm{ namespace detail @@ -75,12 +82,21 @@ namespace detail col_type const & v1, col_type const & v2); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat3x4(std::initializer_list m); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat3x4(std::initializer_list m); - GLM_FUNC_DECL tmat3x4(std::initializer_list > m); -#endif//GLM_HAS_INITIALIZER_LISTS + GLM_FUNC_DECL tmat3x4(std::initializer_list > m); +# endif//GLM_HAS_INITIALIZER_LISTS + +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x4(tmat3x4 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -117,6 +133,16 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](length_t i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x4 & operator=(tmat3x4 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat3x4 & operator= (tmat3x4 const & m); template GLM_FUNC_DECL tmat3x4 & operator= (tmat3x4 const & m); diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index 5f1b4c03..d9fd3825 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -33,7 +33,14 @@ #include "type_vec2.hpp" #include "type_vec4.hpp" #include "type_mat.hpp" +#if GLM_HAS_INITIALIZER_LISTS +# include +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif #include +#include namespace glm{ namespace detail @@ -77,12 +84,22 @@ namespace detail col_type const & v2, col_type const & v3); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat4x2(std::initializer_list m); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat4x2(std::initializer_list m); - GLM_FUNC_DECL tmat4x2(std::initializer_list > m); -#endif//GLM_HAS_INITIALIZER_LISTS + GLM_FUNC_DECL tmat4x2(std::initializer_list > m); +# endif//GLM_HAS_INITIALIZER_LISTS + +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x2(tmat4x2 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + this->value[3] = std::move(m.value[3]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -123,6 +140,17 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](length_t i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x2 & operator=(tmat4x2 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + this->value[3] = std::move(m.value[3]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x2& operator= (tmat4x2 const & m); template GLM_FUNC_DECL tmat4x2& operator= (tmat4x2 const & m); diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index 3b7663dd..65315fcf 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -33,7 +33,14 @@ #include "type_vec3.hpp" #include "type_vec4.hpp" #include "type_mat.hpp" +#if GLM_HAS_INITIALIZER_LISTS +# include +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif #include +#include namespace glm{ namespace detail @@ -77,12 +84,22 @@ namespace detail col_type const & v2, col_type const & v3); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat4x3(std::initializer_list m); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat4x3(std::initializer_list m); + + GLM_FUNC_DECL tmat4x3(std::initializer_list > m); +# endif//GLM_HAS_INITIALIZER_LISTS - GLM_FUNC_DECL tmat4x3(std::initializer_list > m); -#endif//GLM_HAS_INITIALIZER_LISTS +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x3(tmat4x3 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + this->value[3] = std::move(m.value[3]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -123,6 +140,17 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](size_type i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x3 & operator=(tmat4x3 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + this->value[3] = std::move(m.value[3]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x3 & operator= (tmat4x3 const & m); template GLM_FUNC_DECL tmat4x3 & operator= (tmat4x3 const & m); diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index ab5e366a..7b003b72 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -32,9 +32,12 @@ #include "../fwd.hpp" #include "type_vec4.hpp" #include "type_mat.hpp" -#if(GLM_HAS_INITIALIZER_LISTS) +#if GLM_HAS_INITIALIZER_LISTS # include -#endif //GLM_HAS_INITIALIZER_LISTS +#endif +#if GLM_HAS_RVALUE_REFERENCES +# include +#endif #include #include @@ -85,12 +88,22 @@ namespace detail col_type const & v2, col_type const & v3); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tmat4x4(std::initializer_list m); +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat4x4(std::initializer_list m); + + GLM_FUNC_DECL tmat4x4(std::initializer_list > m); +# endif//GLM_HAS_INITIALIZER_LISTS - GLM_FUNC_DECL tmat4x4(std::initializer_list > m); -#endif//GLM_HAS_INITIALIZER_LISTS +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x4(tmat4x4 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + this->value[3] = std::move(m.value[3]); + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) ////////////////////////////////////// // Conversions @@ -131,6 +144,17 @@ namespace detail GLM_FUNC_DECL col_type const & operator[](length_t i) const; // Unary updatable operators +# if(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x4 & operator=(tmat4x4 && m) + { + this->value[0] = std::move(m.value[0]); + this->value[1] = std::move(m.value[1]); + this->value[2] = std::move(m.value[2]); + this->value[3] = std::move(m.value[3]); + return *this; + } +# endif//(GLM_HAS_DEFAULTED_FUNCTIONS && GLM_HAS_RVALUE_REFERENCES) + GLM_FUNC_DECL tmat4x4 & operator= (tmat4x4 const & m); template GLM_FUNC_DECL tmat4x4 & operator= (tmat4x4 const & m); diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 02f0a06d..041dd771 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -82,10 +82,10 @@ namespace detail template GLM_FUNC_DECL tvec1(tvec1 const & v); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tvec1(std::initializer_list const & v); -#endif//GLM_HAS_INITIALIZER_LISTS +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tvec1(std::initializer_list l); +# endif//GLM_HAS_INITIALIZER_LISTS ////////////////////////////////////// // Explicit basic constructors @@ -115,9 +115,9 @@ namespace detail // Unary arithmetic operators GLM_FUNC_DECL tvec1 & operator= (tvec1 const & v); + template GLM_FUNC_DECL tvec1 & operator= (tvec1 const & v); - template GLM_FUNC_DECL tvec1 & operator+=(U const & s); template diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index e315e956..fbfc42b1 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -74,10 +74,10 @@ namespace detail #if(GLM_HAS_INITIALIZER_LISTS) template template - GLM_FUNC_QUALIFIER tvec1::tvec1(std::initializer_list const & v) : - x(static_cast(v.begin()[0])) + GLM_FUNC_QUALIFIER tvec1::tvec1(std::initializer_list l) : + x(static_cast(l.begin()[0])) { - assert(v.size() == this->length()); + assert(l.size() == this->length()); } #endif//GLM_HAS_INITIALIZER_LISTS diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 8dd4cba0..129bb130 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -107,10 +107,10 @@ namespace detail template GLM_FUNC_DECL tvec2(tvec2 const & v); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tvec2(std::initializer_list const & v); -#endif//GLM_HAS_INITIALIZER_LISTS +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tvec2(std::initializer_list l); +# endif//GLM_HAS_INITIALIZER_LISTS ////////////////////////////////////// // Explicit basic constructors @@ -127,11 +127,11 @@ namespace detail // Swizzle constructors # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) - template - GLM_FUNC_DECL tvec2(_swizzle<2,T, P, tvec2, E0, E1,-1,-2> const & that) - { - *this = that(); - } + template + GLM_FUNC_DECL tvec2(_swizzle<2,T, P, tvec2, E0, E1,-1,-2> const & that) + { + *this = that(); + } # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) ////////////////////////////////////// @@ -160,9 +160,9 @@ namespace detail // Unary arithmetic operators GLM_FUNC_DECL tvec2 & operator= (tvec2 const & v); + template GLM_FUNC_DECL tvec2 & operator= (tvec2 const & v); - template GLM_FUNC_DECL tvec2 & operator+=(U s); template diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 03857005..fb9b8f87 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -77,11 +77,11 @@ namespace detail #if(GLM_HAS_INITIALIZER_LISTS) template template - GLM_FUNC_QUALIFIER tvec2::tvec2(std::initializer_list const & v) : - x(static_cast(v.begin()[0])), - y(static_cast(v.begin()[1])) + GLM_FUNC_QUALIFIER tvec2::tvec2(std::initializer_list l) : + x(static_cast(l.begin()[0])), + y(static_cast(l.begin()[1])) { - assert(v.size() == this->length()); + assert(l.size() == this->length()); } #endif//GLM_HAS_INITIALIZER_LISTS diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 5718557a..1e6d5c37 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -108,10 +108,10 @@ namespace detail template GLM_FUNC_DECL tvec3(tvec3 const & v); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tvec3(std::initializer_list const & v); -#endif//GLM_HAS_INITIALIZER_LISTS +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tvec3(std::initializer_list l); +# endif//GLM_HAS_INITIALIZER_LISTS ////////////////////////////////////// // Explicit basic constructors @@ -155,32 +155,32 @@ namespace detail // Swizzle constructors # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) - template - GLM_FUNC_DECL tvec3(_swizzle<3, T, P, tvec3, E0, E1, E2, -1> const & that) - { - *this = that(); - } - - template - GLM_FUNC_DECL tvec3(_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, T const & s) - { - *this = tvec3(v(), s); - } - - template - GLM_FUNC_DECL tvec3(T const & s, _swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v) - { - *this = tvec3(s, v()); - } + template + GLM_FUNC_DECL tvec3(_swizzle<3, T, P, tvec3, E0, E1, E2, -1> const & that) + { + *this = that(); + } + + template + GLM_FUNC_DECL tvec3(_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, T const & s) + { + *this = tvec3(v(), s); + } + + template + GLM_FUNC_DECL tvec3(T const & s, _swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v) + { + *this = tvec3(s, v()); + } # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) ////////////////////////////////////// // Unary arithmetic operators GLM_FUNC_DECL tvec3 & operator= (tvec3 const & v); + template GLM_FUNC_DECL tvec3 & operator= (tvec3 const & v); - template GLM_FUNC_DECL tvec3 & operator+=(U s); template diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index e98201f8..cb5879dc 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -80,12 +80,12 @@ namespace detail #if(GLM_HAS_INITIALIZER_LISTS) template template - GLM_FUNC_QUALIFIER tvec3::tvec3(std::initializer_list const & v) : - x(static_cast(v.begin()[0])), - y(static_cast(v.begin()[1])), - z(static_cast(v.begin()[2])) + GLM_FUNC_QUALIFIER tvec3::tvec3(std::initializer_list l) : + x(static_cast(l.begin()[0])), + y(static_cast(l.begin()[1])), + z(static_cast(l.begin()[2])) { - assert(v.size() == this->length()); + assert(l.size() == this->length()); } #endif//GLM_HAS_INITIALIZER_LISTS diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 0dd9c364..e220a29f 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -147,10 +147,10 @@ namespace detail template GLM_FUNC_DECL tvec4(tvec4 const & v); -#if(GLM_HAS_INITIALIZER_LISTS) - template - GLM_FUNC_DECL tvec4(std::initializer_list l); -#endif//GLM_HAS_INITIALIZER_LISTS +# if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tvec4(std::initializer_list l); +# endif//GLM_HAS_INITIALIZER_LISTS ////////////////////////////////////// // Explicit basic constructors @@ -205,53 +205,54 @@ namespace detail // Swizzle constructors # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) - template - GLM_FUNC_DECL tvec4(_swizzle<4, T, P, tvec4, E0, E1, E2, E3> const & that) - { - *this = that(); - } + template + GLM_FUNC_DECL tvec4(_swizzle<4, T, P, tvec4, E0, E1, E2, E3> const & that) + { + *this = that(); + } - template - GLM_FUNC_DECL tvec4(_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, _swizzle<2, T, P, tvec2, F0, F1, -1, -2> const & u) - { - *this = tvec4(v(), u()); - } + template + GLM_FUNC_DECL tvec4(_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, _swizzle<2, T, P, tvec2, F0, F1, -1, -2> const & u) + { + *this = tvec4(v(), u()); + } - template - GLM_FUNC_DECL tvec4(T const & x, T const & y, _swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v) - { - *this = tvec4(x, y, v()); - } + template + GLM_FUNC_DECL tvec4(T const & x, T const & y, _swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v) + { + *this = tvec4(x, y, v()); + } - template - GLM_FUNC_DECL tvec4(T const & x, _swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, T const & w) - { - *this = tvec4(x, v(), w); - } + template + GLM_FUNC_DECL tvec4(T const & x, _swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, T const & w) + { + *this = tvec4(x, v(), w); + } - template - GLM_FUNC_DECL tvec4(_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, T const & z, T const & w) - { - *this = tvec4(v(), z, w); - } + template + GLM_FUNC_DECL tvec4(_swizzle<2, T, P, tvec2, E0, E1, -1, -2> const & v, T const & z, T const & w) + { + *this = tvec4(v(), z, w); + } - template - GLM_FUNC_DECL tvec4(_swizzle<3, T, P, tvec3, E0, E1, E2, -1> const & v, T const & w) - { - *this = tvec4(v(), w); - } + template + GLM_FUNC_DECL tvec4(_swizzle<3, T, P, tvec3, E0, E1, E2, -1> const & v, T const & w) + { + *this = tvec4(v(), w); + } - template - GLM_FUNC_DECL tvec4(T const & x, _swizzle<3, T, P, tvec3, E0, E1, E2, -1> const & v) - { - *this = tvec4(x, v()); - } + template + GLM_FUNC_DECL tvec4(T const & x, _swizzle<3, T, P, tvec3, E0, E1, E2, -1> const & v) + { + *this = tvec4(x, v()); + } # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) ////////////////////////////////////// // Unary arithmetic operators GLM_FUNC_DECL tvec4 & operator= (tvec4 const & v); + GLM_FUNC_DECL tvec4 & operator+=(T s); GLM_FUNC_DECL tvec4 & operator+=(tvec4 const & v); GLM_FUNC_DECL tvec4 & operator-=(T s); diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 39cf8180..b366300f 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -121,13 +121,13 @@ namespace detail #if(GLM_HAS_INITIALIZER_LISTS) template template - GLM_FUNC_QUALIFIER tvec4::tvec4(std::initializer_list v) : - x(static_cast(v.begin()[0])), - y(static_cast(v.begin()[1])), - z(static_cast(v.begin()[2])), - w(static_cast(v.begin()[3])) + GLM_FUNC_QUALIFIER tvec4::tvec4(std::initializer_list l) : + x(static_cast(l.begin()[0])), + y(static_cast(l.begin()[1])), + z(static_cast(l.begin()[2])), + w(static_cast(l.begin()[3])) { - assert(v.size() == this->length()); + assert(l.size() == this->length()); } #endif//GLM_HAS_INITIALIZER_LISTS diff --git a/readme.txt b/readme.txt index cfc1b99c..603d6cf7 100644 --- a/readme.txt +++ b/readme.txt @@ -42,6 +42,7 @@ GLM 0.9.6.0: 2014-XX-XX - Added transparent use of SIMD instructions for vec4 and mat4 types - Removed degrees for function parameters - Removed GLM_FORCE_RADIANS, active by default +- Added move contructors and assignment operators (#141) ================================================================================ GLM 0.9.5.2: 2014-0X-XX