More use of initializer lists

This commit is contained in:
Christophe Riccio 2018-07-10 11:52:00 +02:00
parent 3308b75836
commit e48c5ae892
12 changed files with 55 additions and 106 deletions

View File

@ -35,7 +35,6 @@ namespace glm
// -- Constructors -- // -- Constructors --
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 2, T, Q> const& m) GLM_DEFAULT;
template<qualifier P> template<qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 2, T, P> const& m); GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 2, T, P> const& m);

View File

@ -10,28 +10,22 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0), col_type(0, 1)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0); this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1); this->value[1] = col_type(0, 1);
# endif # endif
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat(mat<2, 2, T, Q> const& m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat(mat<2, 2, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat(mat<2, 2, T, P> const& m)
# if GLM_HAS_INITIALIZER_LISTS # if GLM_HAS_INITIALIZER_LISTS
: value{m.value[0], m.value[1]} : value{m[0], m[1]}
# endif # endif
{ {
# if !GLM_HAS_INITIALIZER_LISTS # if !GLM_HAS_INITIALIZER_LISTS

View File

@ -36,7 +36,6 @@ namespace glm
// -- Constructors -- // -- Constructors --
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat() GLM_DEFAULT_CTOR; GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat() GLM_DEFAULT_CTOR;
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 3, T, Q> const& m) GLM_DEFAULT;
template<qualifier P> template<qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 3, T, P> const& m); GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 3, T, P> const& m);

View File

@ -8,29 +8,28 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0, 0), col_type(0, 1, 0)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0, 0); this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0); this->value[1] = col_type(0, 1, 0);
# endif # endif
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat(mat<2, 3, T, Q> const& m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat(mat<2, 3, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat(mat<2, 3, T, P> const& m)
# if GLM_HAS_INITIALIZER_LISTS
: value{m.value[0], m.value[1]}
# endif
{ {
# if !GLM_HAS_INITIALIZER_LISTS
this->value[0] = m.value[0]; this->value[0] = m.value[0];
this->value[1] = m.value[1]; this->value[1] = m.value[1];
# endif
} }
template<typename T, qualifier Q> template<typename T, qualifier Q>

View File

@ -8,23 +8,17 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0, 0, 0); this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0); this->value[1] = col_type(0, 1, 0, 0);
# endif # endif
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat(mat<2, 4, T, Q> const& m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat(mat<2, 4, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat(mat<2, 4, T, P> const& m)

View File

@ -8,8 +8,11 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0), col_type(0, 1), col_type(0, 0)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0); this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1); this->value[1] = col_type(0, 1);
this->value[2] = col_type(0, 0); this->value[2] = col_type(0, 0);
@ -17,16 +20,6 @@ namespace glm
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat(mat<3, 2, T, Q> const& m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat(mat<3, 2, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat(mat<3, 2, T, P> const& m)

View File

@ -10,8 +10,11 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0, 0), col_type(0, 1, 0), col_type(0, 0, 1)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0, 0); this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0); this->value[1] = col_type(0, 1, 0);
this->value[2] = col_type(0, 0, 1); this->value[2] = col_type(0, 0, 1);
@ -19,16 +22,6 @@ namespace glm
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat(mat<3, 3, T, Q> const& m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat(mat<3, 3, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat(mat<3, 3, T, P> const& m)

View File

@ -8,8 +8,11 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0), col_type(0, 0, 1, 0)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0, 0, 0); this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0); this->value[1] = col_type(0, 1, 0, 0);
this->value[2] = col_type(0, 0, 1, 0); this->value[2] = col_type(0, 0, 1, 0);
@ -17,16 +20,6 @@ namespace glm
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat(mat<3, 4, T, Q> const& m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat(mat<3, 4, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat(mat<3, 4, T, P> const& m)

View File

@ -8,8 +8,11 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0), col_type(0, 1), col_type(0, 0), col_type(0, 0)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0); this->value[0] = col_type(1, 0);
this->value[1] = col_type(0, 1); this->value[1] = col_type(0, 1);
this->value[2] = col_type(0, 0); this->value[2] = col_type(0, 0);
@ -18,17 +21,6 @@ namespace glm
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat(mat<4, 2, T, Q> const& m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
this->value[3] = m.value[3];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat(mat<4, 2, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat(mat<4, 2, T, P> const& m)

View File

@ -8,8 +8,11 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0, 0), col_type(0, 1, 0), col_type(0, 0, 1), col_type(0, 0, 0)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0, 0); this->value[0] = col_type(1, 0, 0);
this->value[1] = col_type(0, 1, 0); this->value[1] = col_type(0, 1, 0);
this->value[2] = col_type(0, 0, 1); this->value[2] = col_type(0, 0, 1);
@ -18,17 +21,6 @@ namespace glm
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat(mat<4, 3, T, Q> const& m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
this->value[3] = m.value[3];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat(mat<4, 3, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat(mat<4, 3, T, P> const& m)

View File

@ -10,8 +10,11 @@ namespace glm
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat()
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
: value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0), col_type(0, 0, 1, 0), col_type(0, 0, 0, 1)}
# endif
{ {
# ifdef GLM_FORCE_CTOR_INIT # if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
this->value[0] = col_type(1, 0, 0, 0); this->value[0] = col_type(1, 0, 0, 0);
this->value[1] = col_type(0, 1, 0, 0); this->value[1] = col_type(0, 1, 0, 0);
this->value[2] = col_type(0, 0, 1, 0); this->value[2] = col_type(0, 0, 1, 0);
@ -20,17 +23,6 @@ namespace glm
} }
# endif # endif
# if !GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat(mat<4, 4, T, Q> const& m)
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = m[2];
this->value[3] = m[3];
}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<qualifier P> template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat(mat<4, 4, T, P> const& m) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat(mat<4, 4, T, P> const& m)

View File

@ -57,7 +57,16 @@ int test_inverse()
int test_ctr() int test_ctr()
{ {
int Error(0); int Error = 0;
{
glm::mediump_mat2x2 const A(1.0f);
glm::highp_mat2x2 const B(A);
glm::mediump_mat2x2 const C(B);
for(glm::length_t i = 0; i < A.length(); ++i)
Error += glm::all(glm::equal(A[i], C[i])) ? 0 : 1;
}
#if GLM_HAS_INITIALIZER_LISTS #if GLM_HAS_INITIALIZER_LISTS
glm::mat2x2 m0( glm::mat2x2 m0(