From b43fa52360ac11d0573dd5ee592061ef7a9ea011 Mon Sep 17 00:00:00 2001 From: Amaury Le Leyzour Date: Wed, 2 Sep 2020 11:45:26 -0700 Subject: [PATCH] Change the logic of defaulted constructors Defaulted functions should not impact the constructor if the user requests GLM_FORCE_CTOR_INIT. --- glm/detail/setup.hpp | 10 +++++++++- glm/detail/type_mat2x2.hpp | 2 +- glm/detail/type_mat2x2.inl | 2 +- glm/detail/type_mat2x3.hpp | 2 +- glm/detail/type_mat2x3.inl | 2 +- glm/detail/type_mat2x4.hpp | 2 +- glm/detail/type_mat2x4.inl | 2 +- glm/detail/type_mat3x2.hpp | 2 +- glm/detail/type_mat3x2.inl | 2 +- glm/detail/type_mat3x3.hpp | 2 +- glm/detail/type_mat3x3.inl | 2 +- glm/detail/type_mat3x4.hpp | 2 +- glm/detail/type_mat3x4.inl | 2 +- glm/detail/type_mat4x2.hpp | 2 +- glm/detail/type_mat4x2.inl | 2 +- glm/detail/type_mat4x3.hpp | 2 +- glm/detail/type_mat4x3.inl | 2 +- glm/detail/type_mat4x4.hpp | 2 +- glm/detail/type_mat4x4.inl | 2 +- glm/detail/type_quat.hpp | 2 +- glm/detail/type_quat.inl | 4 +++- glm/detail/type_vec1.hpp | 2 +- glm/detail/type_vec1.inl | 4 +++- glm/detail/type_vec2.hpp | 2 +- glm/detail/type_vec2.inl | 4 +++- glm/detail/type_vec3.hpp | 2 +- glm/detail/type_vec3.inl | 4 +++- glm/detail/type_vec4.hpp | 2 +- glm/detail/type_vec4.inl | 4 +++- 29 files changed, 47 insertions(+), 29 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index a2244e26..a6bfec8a 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -806,7 +806,7 @@ namespace detail /////////////////////////////////////////////////////////////////////////////////// // Configure the use of defaulted function -#if GLM_HAS_DEFAULTED_FUNCTIONS && GLM_CONFIG_CTOR_INIT == GLM_CTOR_INIT_DISABLE +#if GLM_HAS_DEFAULTED_FUNCTIONS # define GLM_CONFIG_DEFAULTED_FUNCTIONS GLM_ENABLE # define GLM_DEFAULT = default #else @@ -814,6 +814,14 @@ namespace detail # define GLM_DEFAULT #endif +#if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INIT_DISABLE && GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE +# define GLM_CONFIG_DEFAULTED_DEFAULT_CTOR GLM_ENABLE +# define GLM_DEFAULT_CTOR GLM_DEFAULT +#else +# define GLM_CONFIG_DEFAULTED_DEFAULT_CTOR GLM_DISABLE +# define GLM_DEFAULT_CTOR +#endif + /////////////////////////////////////////////////////////////////////////////////// // Configure the use of aligned gentypes diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index 033908f4..827022dd 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -32,7 +32,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<2, 2, T, P> const& m); diff --git a/glm/detail/type_mat2x2.inl b/glm/detail/type_mat2x2.inl index fe5d1aa3..33159a6a 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -4,7 +4,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index d6596e46..c9303cba 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -33,7 +33,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<2, 3, T, P> const& m); diff --git a/glm/detail/type_mat2x3.inl b/glm/detail/type_mat2x3.inl index 5fec17e5..c158a5da 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -2,7 +2,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index ff03e215..f7697962 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -33,7 +33,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<2, 4, T, P> const& m); diff --git a/glm/detail/type_mat2x4.inl b/glm/detail/type_mat2x4.inl index b6d2b9dd..2a96d3d4 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -2,7 +2,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index e1665813..d528af03 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -33,7 +33,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<3, 2, T, P> const& m); diff --git a/glm/detail/type_mat3x2.inl b/glm/detail/type_mat3x2.inl index b4b948b7..8cf8ed3f 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -2,7 +2,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index 3174872e..9b435aea 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -32,7 +32,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<3, 3, T, P> const& m); diff --git a/glm/detail/type_mat3x3.inl b/glm/detail/type_mat3x3.inl index 1ddaf99d..4362d84a 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -4,7 +4,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index 6e40b903..27bc425f 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -33,7 +33,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<3, 4, T, P> const& m); diff --git a/glm/detail/type_mat3x4.inl b/glm/detail/type_mat3x4.inl index 6ee416cf..c1a0fa6d 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -2,7 +2,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index 8d343527..56f500d7 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -33,7 +33,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<4, 2, T, P> const& m); diff --git a/glm/detail/type_mat4x2.inl b/glm/detail/type_mat4x2.inl index 419c80c4..efe58330 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -2,7 +2,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index 16e42705..5a4668f7 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -33,7 +33,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<4, 3, T, P> const& m); diff --git a/glm/detail/type_mat4x3.inl b/glm/detail/type_mat4x3.inl index 11b1ee35..1249e958 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -2,7 +2,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index 3517f9f5..b92e2080 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -32,7 +32,7 @@ namespace glm // -- Constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR; template GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<4, 4, T, P> const& m); diff --git a/glm/detail/type_mat4x4.inl b/glm/detail/type_mat4x4.inl index e38b87f7..5c2166ea 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -4,7 +4,7 @@ namespace glm { // -- Constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST diff --git a/glm/detail/type_quat.hpp b/glm/detail/type_quat.hpp index 0e60bc33..daeaa707 100644 --- a/glm/detail/type_quat.hpp +++ b/glm/detail/type_quat.hpp @@ -80,7 +80,7 @@ namespace glm // -- Implicit basic constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR qua() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR qua() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR qua(qua const& q) GLM_DEFAULT; template GLM_FUNC_DECL GLM_CONSTEXPR qua(qua const& q); diff --git a/glm/detail/type_quat.inl b/glm/detail/type_quat.inl index 67b9310a..e7616e40 100644 --- a/glm/detail/type_quat.inl +++ b/glm/detail/type_quat.inl @@ -94,7 +94,7 @@ namespace detail // -- Implicit basic constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua() # if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE @@ -105,7 +105,9 @@ namespace detail # endif # endif {} +# endif +# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) # ifdef GLM_FORCE_QUAT_DATA_WXYZ diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 51163f14..ed381cc4 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -92,7 +92,7 @@ namespace glm // -- Implicit basic constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR vec(vec const& v) GLM_DEFAULT; template GLM_FUNC_DECL GLM_CONSTEXPR vec(vec<1, T, P> const& v); diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index c5883ceb..52a9b3a5 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -6,14 +6,16 @@ namespace glm { // -- Implicit basic constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q>::vec() # if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE : x(0) # endif {} +# endif +# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q>::vec(vec<1, T, Q> const& v) : x(v.x) diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 3899f8dd..5aa969d7 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -94,7 +94,7 @@ namespace glm // -- Implicit basic constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR vec(vec const& v) GLM_DEFAULT; template GLM_FUNC_DECL GLM_CONSTEXPR vec(vec<2, T, P> const& v); diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 8e65d6bb..55ab64d4 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -6,14 +6,16 @@ namespace glm { // -- Implicit basic constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q>::vec() # if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE : x(0), y(0) # endif {} +# endif +# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q>::vec(vec<2, T, Q> const& v) : x(v.x), y(v.y) diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 4dff6551..cfc50006 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -98,7 +98,7 @@ namespace glm // -- Implicit basic constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR vec(vec const& v) GLM_DEFAULT; template GLM_FUNC_DECL GLM_CONSTEXPR vec(vec<3, T, P> const& v); diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index 6532c9e6..8d15db85 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -6,14 +6,16 @@ namespace glm { // -- Implicit basic constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q>::vec() # if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE : x(0), y(0), z(0) # endif {} +# endif +# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q>::vec(vec<3, T, Q> const& v) : x(v.x), y(v.y), z(v.z) diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 8eca4141..fbe8c0e5 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -97,7 +97,7 @@ namespace glm // -- Implicit basic constructors -- - GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT; + GLM_FUNC_DECL GLM_CONSTEXPR vec() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR vec(vec<4, T, Q> const& v) GLM_DEFAULT; template GLM_FUNC_DECL GLM_CONSTEXPR vec(vec<4, T, P> const& v); diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 3c212d98..f520c095 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -129,14 +129,16 @@ namespace detail // -- Implicit basic constructors -- -# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE +# if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q>::vec() # if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE : x(0), y(0), z(0), w(0) # endif {} +# endif +# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q>::vec(vec<4, T, Q> const& v) : x(v.x), y(v.y), z(v.z), w(v.w)