Added C++ 11 initializer list for matrix types

This commit is contained in:
Christophe Riccio
2013-10-01 01:12:21 +02:00
parent 2badec664f
commit 9b1f079856
18 changed files with 304 additions and 0 deletions

View File

@@ -82,6 +82,13 @@ namespace detail
col_type const & v1,
col_type const & v2);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tmat2x2(std::initializer_list<U> m);
GLM_FUNC_DECL tmat2x2(std::initializer_list<tvec2<T, P> > m);
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversions
template <typename U>

View File

@@ -141,6 +141,27 @@ namespace detail
this->value[1] = v1;
}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2(std::initializer_list<U> m)
{
assert(m.size() >= this->length());
typename std::initializer_list<U>::iterator p = m.begin();
this->value[0] = tvec2<T, P>(*(p + 0), *(p + 1));
this->value[1] = tvec2<T, P>(*(p + 2), *(p + 3));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2(std::initializer_list<tvec2<T, P> > m)
{
this->value[0] = m.begin()[0];
this->value[1] = m.begin()[1];
}
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversion constructors
template <typename T, precision P>

View File

@@ -76,6 +76,13 @@ namespace detail
col_type const & v0,
col_type const & v1);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tmat2x3(std::initializer_list<U> m);
GLM_FUNC_DECL tmat2x3(std::initializer_list<tvec3<T, P> > m);
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversions
template <typename U>

View File

@@ -140,6 +140,27 @@ namespace detail
this->value[1] = v1;
}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(std::initializer_list<U> m)
{
assert(m.size() >= this->length());
typename std::initializer_list<U>::iterator p = m.begin();
this->value[0] = tvec3<T, P>(*(p + 0), *(p + 1), *(p + 2));
this->value[1] = tvec3<T, P>(*(p + 3), *(p + 4), *(p + 5));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(std::initializer_list<tvec3<T, P> > m)
{
this->value[0] = m.begin()[0];
this->value[1] = m.begin()[1];
}
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversion constructors
template <typename T, precision P>

View File

@@ -76,6 +76,13 @@ namespace detail
col_type const & v0,
col_type const & v1);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tmat2x4(std::initializer_list<U> m);
GLM_FUNC_DECL tmat2x4(std::initializer_list<tvec4<T, P> > m);
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversions
template <typename U>

View File

@@ -143,6 +143,27 @@ namespace detail
this->value[1] = v1;
}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4(std::initializer_list<U> m)
{
assert(m.size() >= this->length());
typename std::initializer_list<U>::iterator p = m.begin();
this->value[0] = tvec4<T, P>(*(p + 0), *(p + 1), *(p + 2), *(p + 3));
this->value[1] = tvec4<T, P>(*(p + 4), *(p + 5), *(p + 6), *(p + 7));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4(std::initializer_list<tvec4<T, P> > m)
{
this->value[0] = m.begin()[0];
this->value[1] = m.begin()[1];
}
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversion constructors
template <typename T, precision P>

View File

@@ -78,6 +78,13 @@ namespace detail
col_type const & v1,
col_type const & v2);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tmat3x2(std::initializer_list<U> m);
GLM_FUNC_DECL tmat3x2(std::initializer_list<tvec2<T, P> > m);
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversions
template <typename U>

View File

@@ -148,6 +148,29 @@ namespace detail
this->value[2] = v2;
}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(std::initializer_list<U> m)
{
assert(m.size() >= this->length());
typename std::initializer_list<U>::iterator p = m.begin();
this->value[0] = tvec2<T, P>(*(p + 0), *(p + 1));
this->value[1] = tvec2<T, P>(*(p + 2), *(p + 3));
this->value[2] = tvec2<T, P>(*(p + 4), *(p + 5));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(std::initializer_list<tvec2<T, P> > m)
{
this->value[0] = m.begin()[0];
this->value[1] = m.begin()[1];
this->value[2] = m.begin()[2];
}
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversion constructors
template <typename T, precision P>

View File

@@ -83,6 +83,13 @@ namespace detail
col_type const & v1,
col_type const & v2);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tmat3x3(std::initializer_list<U> m);
GLM_FUNC_DECL tmat3x3(std::initializer_list<tvec3<T, P> > m);
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversions
template <typename U>

View File

@@ -151,6 +151,29 @@ namespace detail
this->value[2] = v2;
}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3(std::initializer_list<U> m)
{
assert(m.size() >= this->length());
typename std::initializer_list<U>::iterator p = m.begin();
this->value[0] = tvec3<T, P>(*(p + 0), *(p + 1), *(p + 2));
this->value[1] = tvec3<T, P>(*(p + 3), *(p + 4), *(p + 5));
this->value[2] = tvec3<T, P>(*(p + 6), *(p + 7), *(p + 8));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3(std::initializer_list<tvec3<T, P> > m)
{
this->value[0] = m.begin()[0];
this->value[1] = m.begin()[1];
this->value[2] = m.begin()[2];
}
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversion constructors
template <typename T, precision P>

View File

@@ -78,6 +78,13 @@ namespace detail
col_type const & v1,
col_type const & v2);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tmat3x4(std::initializer_list<U> m);
GLM_FUNC_DECL tmat3x4(std::initializer_list<tvec4<T, P> > m);
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversions
template <typename U>

View File

@@ -195,6 +195,29 @@ namespace detail
this->value[2] = col_type(v3);
}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4(std::initializer_list<U> m)
{
assert(m.size() >= this->length());
typename std::initializer_list<U>::iterator p = m.begin();
this->value[0] = tvec4<T, P>(*(p + 0), *(p + 1), *(p + 2), *(p + 3));
this->value[1] = tvec4<T, P>(*(p + 4), *(p + 5), *(p + 6), *(p + 7));
this->value[2] = tvec4<T, P>(*(p + 8), *(p + 9), *(p + 10), *(p + 11));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4(std::initializer_list<tvec4<T, P> > m)
{
this->value[0] = m.begin()[0];
this->value[1] = m.begin()[1];
this->value[2] = m.begin()[2];
}
#endif//GLM_HAS_INITIALIZER_LISTS
// Conversion
template <typename T, precision P>
template <typename U, precision Q>

View File

@@ -80,6 +80,13 @@ namespace detail
col_type const & v2,
col_type const & v3);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tmat4x2(std::initializer_list<U> m);
GLM_FUNC_DECL tmat4x2(std::initializer_list<tvec2<T, P> > m);
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversions
template <typename U>

View File

@@ -206,6 +206,32 @@ namespace detail
this->value[3] = col_type(v4);
}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(std::initializer_list<U> m)
{
assert(m.size() >= this->length());
typename std::initializer_list<U>::iterator p = m.begin();
this->value[0] = tvec2<T, P>(*(p + 0), *(p + 1));
this->value[1] = tvec2<T, P>(*(p + 2), *(p + 3));
this->value[2] = tvec2<T, P>(*(p + 4), *(p + 5));
this->value[3] = tvec2<T, P>(*(p + 6), *(p + 7));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(std::initializer_list<tvec2<T, P> > m)
{
this->value[0] = m.begin()[0];
this->value[1] = m.begin()[1];
this->value[2] = m.begin()[2];
this->value[3] = m.begin()[3];
}
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversion
template <typename T, precision P>
template <typename U, precision Q>

View File

@@ -80,6 +80,13 @@ namespace detail
col_type const & v2,
col_type const & v3);
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename U>
GLM_FUNC_DECL tmat4x3(std::initializer_list<U> m);
GLM_FUNC_DECL tmat4x3(std::initializer_list<tvec3<T, P> > m);
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversions
template <typename U>

View File

@@ -152,6 +152,31 @@ namespace detail
this->value[3] = v3;
}
#if(GLM_HAS_INITIALIZER_LISTS)
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3(std::initializer_list<U> m)
{
assert(m.size() >= this->length());
typename std::initializer_list<U>::iterator p = m.begin();
this->value[0] = tvec3<T, P>(*(p + 0), *(p + 1), *(p + 2));
this->value[1] = tvec3<T, P>(*(p + 3), *(p + 4), *(p + 5));
this->value[2] = tvec3<T, P>(*(p + 6), *(p + 7), *(p + 8));
this->value[3] = tvec3<T, P>(*(p + 9), *(p + 10), *(p + 11));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3(std::initializer_list<tvec3<T, P> > m)
{
this->value[0] = m.begin()[0];
this->value[1] = m.begin()[1];
this->value[2] = m.begin()[2];
this->value[3] = m.begin()[3];
}
#endif//GLM_HAS_INITIALIZER_LISTS
//////////////////////////////////////
// Conversion constructors
template <typename T, precision P>