Clean up initializer list code.

master
Christophe Riccio ago%!(EXTRA string=12 years)
parent 4e444fed19
commit 31ec3eed97
  1. 3
      glm/detail/type_mat4x4.hpp
  2. 8
      glm/detail/type_vec1.hpp
  3. 10
      glm/detail/type_vec1.inl
  4. 3
      glm/detail/type_vec2.hpp
  5. 3
      glm/detail/type_vec3.hpp
  6. 3
      glm/detail/type_vec4.hpp
  7. 9
      glm/gtc/quaternion.hpp
  8. 13
      glm/gtc/quaternion.inl
  9. 30
      test/core/core_type_mat4x4.cpp
  10. 19
      test/gtc/gtc_quaternion.cpp

@ -32,9 +32,6 @@
#include "../fwd.hpp" #include "../fwd.hpp"
#include "type_vec4.hpp" #include "type_vec4.hpp"
#include "type_mat.hpp" #include "type_mat.hpp"
#if(GLM_HAS_INITIALIZER_LISTS)
# include <initializer_list>
#endif //GLM_HAS_INITIALIZER_LISTS
#include <limits> #include <limits>
#include <cstddef> #include <cstddef>

@ -38,9 +38,6 @@
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
# endif # endif
#endif //GLM_SWIZZLE #endif //GLM_SWIZZLE
#if(GLM_HAS_INITIALIZER_LISTS)
# include <initializer_list>
#endif //GLM_HAS_INITIALIZER_LISTS
#include <cstddef> #include <cstddef>
namespace glm{ namespace glm{
@ -82,11 +79,6 @@ namespace detail
template <precision Q> template <precision Q>
GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v); GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tvec1(std::initializer_list<U> const & v);
#endif//GLM_HAS_INITIALIZER_LISTS
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors

@ -71,16 +71,6 @@ namespace detail
x(v.x) x(v.x)
{} {}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(std::initializer_list<U> const & v) :
x(static_cast<T>(v.begin()[0]))
{
assert(v.size() == this->length());
}
#endif//GLM_HAS_INITIALIZER_LISTS
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors

@ -38,9 +38,6 @@
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
# endif # endif
#endif //GLM_SWIZZLE #endif //GLM_SWIZZLE
#if(GLM_HAS_INITIALIZER_LISTS)
# include <initializer_list>
#endif //GLM_HAS_INITIALIZER_LISTS
#include <cstddef> #include <cstddef>
namespace glm{ namespace glm{

@ -38,9 +38,6 @@
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
# endif # endif
#endif //GLM_SWIZZLE #endif //GLM_SWIZZLE
#if(GLM_HAS_INITIALIZER_LISTS)
# include <initializer_list>
#endif //GLM_HAS_INITIALIZER_LISTS
#include <cstddef> #include <cstddef>
namespace glm{ namespace glm{

@ -39,9 +39,6 @@
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
# endif # endif
#endif //GLM_SWIZZLE #endif //GLM_SWIZZLE
#if(GLM_HAS_INITIALIZER_LISTS)
# include <initializer_list>
#endif //GLM_HAS_INITIALIZER_LISTS
#include <cstddef> #include <cstddef>
namespace glm{ namespace glm{

@ -71,20 +71,15 @@ namespace detail
template <typename U, precision Q> template <typename U, precision Q>
GLM_FUNC_DECL explicit tquat( GLM_FUNC_DECL explicit tquat(
tquat<U, Q> const & q); tquat<U, Q> const & q);
GLM_FUNC_DECL explicit tquat( GLM_FUNC_DECL tquat(
T const & s, T const & s,
tvec3<T, P> const & v); tvec3<T, P> const & v);
GLM_FUNC_DECL explicit tquat( GLM_FUNC_DECL tquat(
T const & w, T const & w,
T const & x, T const & x,
T const & y, T const & y,
T const & z); T const & z);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tquat(std::initializer_list<U> l);
#endif//GLM_HAS_INITIALIZER_LISTS
// Convertions // Convertions
/// Create a quaternion from two normalized axis /// Create a quaternion from two normalized axis

@ -86,19 +86,6 @@ namespace detail
w(w) w(w)
{} {}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(std::initializer_list<U> l) :
x(static_cast<T>(l.begin()[0])),
y(static_cast<T>(l.begin()[1])),
z(static_cast<T>(l.begin()[2])),
w(static_cast<T>(l.begin()[3]))
{
assert(l.size() >= this->length());
}
#endif//GLM_HAS_INITIALIZER_LISTS
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
// tquat conversions // tquat conversions

@ -189,19 +189,6 @@ int test_ctr()
{ {
int Error(0); int Error(0);
{
glm::vec4 V{0, 1, 2, 3};
glm::mat4 M{
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11},
{12, 13, 14, 15}};
}
glm::mat4 m4{
{0, 1, 2, 3}};
#if(GLM_HAS_INITIALIZER_LISTS) #if(GLM_HAS_INITIALIZER_LISTS)
glm::mat4 m0( glm::mat4 m0(
glm::vec4(0, 1, 2, 3), glm::vec4(0, 1, 2, 3),
@ -211,6 +198,8 @@ int test_ctr()
assert(sizeof(m0) == 4 * 4 * 4); assert(sizeof(m0) == 4 * 4 * 4);
glm::vec4 V{0, 1, 2, 3};
glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
glm::mat4 m2{ glm::mat4 m2{
@ -231,19 +220,9 @@ int test_ctr()
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}; {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
/*
std::initializer_list<glm::mat4> m3{
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11},
{12, 13, 14, 15}};
*/
//glm::mat4 m4{m3};
std::vector<glm::mat4> v1{ std::vector<glm::mat4> v1{
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
};
std::vector<glm::mat4> v2{ std::vector<glm::mat4> v2{
{ {
@ -257,8 +236,7 @@ int test_ctr()
{ 4, 5, 6, 7 }, { 4, 5, 6, 7 },
{ 8, 9, 10, 11 }, { 8, 9, 10, 11 },
{ 12, 13, 14, 15 } { 12, 13, 14, 15 }
} }};
};
#endif//GLM_HAS_INITIALIZER_LISTS #endif//GLM_HAS_INITIALIZER_LISTS

@ -11,6 +11,7 @@
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
#include <glm/gtc/epsilon.hpp> #include <glm/gtc/epsilon.hpp>
#include <glm/vector_relational.hpp> #include <glm/vector_relational.hpp>
#include <vector>
int test_quat_angle() int test_quat_angle()
{ {
@ -246,10 +247,28 @@ int test_quat_type()
return 0; return 0;
} }
int test_quat_ctr()
{
int Error(0);
# if(GLM_HAS_INITIALIZER_LISTS)
{
glm::quat A{0, 1, 2, 3};
std::vector<glm::quat> B{
{0, 1, 2, 3},
{0, 1, 2, 3}};
}
# endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main() int main()
{ {
int Error(0); int Error(0);
Error += test_quat_ctr();
Error += test_quat_two_axis_ctr(); Error += test_quat_two_axis_ctr();
Error += test_quat_mul(); Error += test_quat_mul();
Error += test_quat_precision(); Error += test_quat_precision();

Loading…
Cancel
Save