Browse Source

base: use variadic templates to remove 300+ lines of redundant code.

undefined
Sam Hocevar 10 years ago
parent
commit
e49353f457
6 changed files with 66 additions and 430 deletions
  1. +2
    -2
      src/input/input.h
  2. +32
    -396
      src/lol/base/array.h
  3. +17
    -11
      src/lol/base/tuple.h
  4. +5
    -7
      src/lol/math/array2d.h
  5. +7
    -9
      src/lol/math/array3d.h
  6. +3
    -5
      src/lol/math/arraynd.h

+ 2
- 2
src/input/input.h View File

@@ -99,8 +99,8 @@ protected:
private: private:
static array<InputDevice*> devices; static array<InputDevice*> devices;


template <typename T>
int GetItemIndex(const char* name, const array<String, T>& array) const
template <typename... T>
int GetItemIndex(const char* name, const array<String, T...>& array) const
{ {
for (int i = 0; i < array.Count(); ++i) for (int i = 0; i < array.Count(); ++i)
{ {


+ 32
- 396
src/lol/base/array.h View File

@@ -476,419 +476,62 @@ protected:
int m_count, m_reserved; int m_count, m_reserved;
}; };


/*
* element_t types
*/

template<typename T1, typename T2, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void,
typename T8 = void>
class array_element
{
public:
T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6; T7 m7; T8 m8;
};

template<typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
class array_element<T1, T2, T3, T4, T5, T6, T7, void>
{
public:
T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6; T7 m7;
};

template<typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
class array_element<T1, T2, T3, T4, T5, T6, void, void>
{
public:
T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6;
};

template<typename T1, typename T2, typename T3, typename T4, typename T5>
class array_element<T1, T2, T3, T4, T5, void, void, void>
{
public:
T1 m1; T2 m2; T3 m3; T4 m4; T5 m5;
};

template<typename T1, typename T2, typename T3, typename T4>
class array_element<T1, T2, T3, T4, void, void, void, void>
{
public:
T1 m1; T2 m2; T3 m3; T4 m4;
};

template<typename T1, typename T2, typename T3>
class array_element<T1, T2, T3, void, void, void, void, void>
{
public:
T1 m1; T2 m2; T3 m3;
};

template<typename T1, typename T2>
class array_element<T1, T2, void, void, void, void, void, void>
{
public:
T1 m1; T2 m2;
};

/* /*
* array specialisations implementing specific setters * array specialisations implementing specific setters
*/ */


template<typename T1, typename T2 = void, typename T3 = void,
typename T4 = void, typename T5 = void, typename T6 = void,
typename T7 = void, typename T8 = void>
class array : public array_base<array_element<T1, T2, T3, T4, T5, T6, T7, T8>,
array<T1, T2, T3, T4, T5, T6, T7, T8>>
{
#if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS
using array_base<array_element<T1, T2, T3, T4, T5, T6, T7, T8>,
array<T1, T2, T3, T4, T5, T6, T7, T8>>::array_base;
#else
public:
typedef array_element<T1, T2, T3, T4, T5, T6, T7, T8> element_t;

inline array()
: array_base<element_t,
array<T1, T2, T3, T4, T5, T6, T7, T8>>::array_base() {}

inline array(std::initializer_list<element_t> const &list)
: array_base<element_t,
array<T1, T2, T3, T4, T5, T6, T7, T8>>::array_base(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4,
T5 const &m5, T6 const &m6, T7 const &m7, T8 const &m8)
{
if (this->m_count >= this->m_reserved)
{
T1 tmp1 = m1; T2 tmp2 = m2; T3 tmp3 = m3; T4 tmp4 = m4;
T5 tmp5 = m5; T6 tmp6 = m6; T7 tmp7 = m7; T8 tmp8 = m8;
this->Grow();
new (&this->m_data[this->m_count].m1) T1(tmp1);
new (&this->m_data[this->m_count].m2) T2(tmp2);
new (&this->m_data[this->m_count].m3) T3(tmp3);
new (&this->m_data[this->m_count].m4) T4(tmp4);
new (&this->m_data[this->m_count].m5) T5(tmp5);
new (&this->m_data[this->m_count].m6) T6(tmp6);
new (&this->m_data[this->m_count].m7) T7(tmp7);
new (&this->m_data[this->m_count].m8) T8(tmp8);
}
else
{
new (&this->m_data[this->m_count].m1) T1(m1);
new (&this->m_data[this->m_count].m2) T2(m2);
new (&this->m_data[this->m_count].m3) T3(m3);
new (&this->m_data[this->m_count].m4) T4(m4);
new (&this->m_data[this->m_count].m5) T5(m5);
new (&this->m_data[this->m_count].m6) T6(m6);
new (&this->m_data[this->m_count].m7) T7(m7);
new (&this->m_data[this->m_count].m8) T8(m8);
}
++this->m_count;
}
};

template<typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
class array<T1, T2, T3, T4, T5, T6, T7, void>
: public array_base<array_element<T1, T2, T3, T4, T5, T6, T7, void>,
array<T1, T2, T3, T4, T5, T6, T7>>
{
#if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS
using array_base<array_element<T1, T2, T3, T4, T5, T6, T7, void>,
array<T1, T2, T3, T4, T5, T6, T7>>::array_base;
#else
public:
typedef array_element<T1, T2, T3, T4, T5, T6, T7, void> element_t;

inline array()
: array_base<element_t,
array<T1, T2, T3, T4, T5, T6, T7>>::array_base() {}

inline array(std::initializer_list<element_t> const &list)
: array_base<element_t,
array<T1, T2, T3, T4, T5, T6, T7>>::array_base(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4,
T5 const &m5, T6 const &m6, T7 const &m7)
{
if (this->m_count >= this->m_reserved)
{
T1 tmp1 = m1; T2 tmp2 = m2; T3 tmp3 = m3; T4 tmp4 = m4;
T5 tmp5 = m5; T6 tmp6 = m6; T7 tmp7 = m7;
this->Grow();
new (&this->m_data[this->m_count].m1) T1(tmp1);
new (&this->m_data[this->m_count].m2) T2(tmp2);
new (&this->m_data[this->m_count].m3) T3(tmp3);
new (&this->m_data[this->m_count].m4) T4(tmp4);
new (&this->m_data[this->m_count].m5) T5(tmp5);
new (&this->m_data[this->m_count].m6) T6(tmp6);
new (&this->m_data[this->m_count].m7) T7(tmp7);
}
else
{
new (&this->m_data[this->m_count].m1) T1(m1);
new (&this->m_data[this->m_count].m2) T2(m2);
new (&this->m_data[this->m_count].m3) T3(m3);
new (&this->m_data[this->m_count].m4) T4(m4);
new (&this->m_data[this->m_count].m5) T5(m5);
new (&this->m_data[this->m_count].m6) T6(m6);
new (&this->m_data[this->m_count].m7) T7(m7);
}
++this->m_count;
}
};

template<typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
class array<T1, T2, T3, T4, T5, T6, void, void>
: public array_base<array_element<T1, T2, T3, T4, T5, T6, void, void>,
array<T1, T2, T3, T4, T5, T6>>
{
#if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS
using array_base<array_element<T1, T2, T3, T4, T5, T6, void, void>,
array<T1, T2, T3, T4, T5, T6>>::array_base;
#else
public:
typedef array_element<T1, T2, T3, T4, T5, T6, void, void> element_t;

inline array()
: array_base<element_t,
array<T1, T2, T3, T4, T5, T6>>::array_base() {}

inline array(std::initializer_list<element_t> const &list)
: array_base<element_t,
array<T1, T2, T3, T4, T5, T6>>::array_base(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4,
T5 const &m5, T6 const &m6)
{
if (this->m_count >= this->m_reserved)
{
T1 tmp1 = m1; T2 tmp2 = m2; T3 tmp3 = m3; T4 tmp4 = m4;
T5 tmp5 = m5; T6 tmp6 = m6;
this->Grow();
new (&this->m_data[this->m_count].m1) T1(tmp1);
new (&this->m_data[this->m_count].m2) T2(tmp2);
new (&this->m_data[this->m_count].m3) T3(tmp3);
new (&this->m_data[this->m_count].m4) T4(tmp4);
new (&this->m_data[this->m_count].m5) T5(tmp5);
new (&this->m_data[this->m_count].m6) T6(tmp6);
}
else
{
new (&this->m_data[this->m_count].m1) T1(m1);
new (&this->m_data[this->m_count].m2) T2(m2);
new (&this->m_data[this->m_count].m3) T3(m3);
new (&this->m_data[this->m_count].m4) T4(m4);
new (&this->m_data[this->m_count].m5) T5(m5);
new (&this->m_data[this->m_count].m6) T6(m6);
}
++this->m_count;
}
};

template<typename T1, typename T2, typename T3, typename T4, typename T5>
class array<T1, T2, T3, T4, T5, void, void, void>
: public array_base<array_element<T1, T2, T3, T4, T5, void, void, void>,
array<T1, T2, T3, T4, T5>>
{
#if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS
using array_base<array_element<T1, T2, T3, T4, T5, void, void, void>,
array<T1, T2, T3, T4, T5>>::array_base;
#else
public:
typedef array_element<T1, T2, T3, T4, T5, void, void, void> element_t;

inline array()
: array_base<element_t,
array<T1, T2, T3, T4, T5>>::array_base() {}

inline array(std::initializer_list<element_t> const &list)
: array_base<element_t,
array<T1, T2, T3, T4, T5>>::array_base(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4,
T5 const &m5)
{
if (this->m_count >= this->m_reserved)
{
T1 tmp1 = m1; T2 tmp2 = m2; T3 tmp3 = m3; T4 tmp4 = m4;
T5 tmp5 = m5;
this->Grow();
new (&this->m_data[this->m_count].m1) T1(tmp1);
new (&this->m_data[this->m_count].m2) T2(tmp2);
new (&this->m_data[this->m_count].m3) T3(tmp3);
new (&this->m_data[this->m_count].m4) T4(tmp4);
new (&this->m_data[this->m_count].m5) T5(tmp5);
}
else
{
new (&this->m_data[this->m_count].m1) T1(m1);
new (&this->m_data[this->m_count].m2) T2(m2);
new (&this->m_data[this->m_count].m3) T3(m3);
new (&this->m_data[this->m_count].m4) T4(m4);
new (&this->m_data[this->m_count].m5) T5(m5);
}
++this->m_count;
}
};

template<typename T1, typename T2, typename T3, typename T4>
class array<T1, T2, T3, T4, void, void, void, void>
: public array_base<array_element<T1, T2, T3, T4, void, void, void, void>,
array<T1, T2, T3, T4>>
{
#if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS
using array_base<array_element<T1, T2, T3, T4, void, void, void, void>,
array<T1, T2, T3, T4>>::array_base;
#else
public:
typedef array_element<T1, T2, T3, T4, void, void, void, void> element_t;

inline array()
: array_base<element_t,
array<T1, T2, T3, T4>>::array_base() {}

inline array(std::initializer_list<element_t> const &list)
: array_base<element_t,
array<T1, T2, T3, T4>>::array_base(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3, T4 const &m4)
{
if (this->m_count >= this->m_reserved)
{
T1 tmp1 = m1; T2 tmp2 = m2; T3 tmp3 = m3; T4 tmp4 = m4;
this->Grow();
new (&this->m_data[this->m_count].m1) T1(tmp1);
new (&this->m_data[this->m_count].m2) T2(tmp2);
new (&this->m_data[this->m_count].m3) T3(tmp3);
new (&this->m_data[this->m_count].m4) T4(tmp4);
}
else
{
new (&this->m_data[this->m_count].m1) T1(m1);
new (&this->m_data[this->m_count].m2) T2(m2);
new (&this->m_data[this->m_count].m3) T3(m3);
new (&this->m_data[this->m_count].m4) T4(m4);
}
++this->m_count;
}
};

template<typename T1, typename T2, typename T3>
class array<T1, T2, T3, void, void, void, void, void>
: public array_base<array_element<T1, T2, T3, void, void, void, void, void>,
array<T1, T2, T3>>
{
#if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS
using array_base<array_element<T1, T2, T3, void, void, void, void, void>,
array<T1, T2, T3>>::array_base;
#else
public:
typedef array_element<T1, T2, T3, void, void, void, void, void> element_t;

inline array()
: array_base<element_t,
array<T1, T2, T3>>::array_base() {}

inline array(std::initializer_list<element_t> const &list)
: array_base<element_t,
array<T1, T2, T3>>::array_base(list) {}
#endif

public:
inline void Push(T1 const &m1, T2 const &m2, T3 const &m3)
{
if (this->m_count >= this->m_reserved)
{
T1 tmp1 = m1; T2 tmp2 = m2; T3 tmp3 = m3;
this->Grow();
new (&this->m_data[this->m_count].m1) T1(tmp1);
new (&this->m_data[this->m_count].m2) T2(tmp2);
new (&this->m_data[this->m_count].m3) T3(tmp3);
}
else
{
new (&this->m_data[this->m_count].m1) T1(m1);
new (&this->m_data[this->m_count].m2) T2(m2);
new (&this->m_data[this->m_count].m3) T3(m3);
}
++this->m_count;
}
};

template<typename T1, typename T2>
class array<T1, T2, void, void, void, void, void, void>
: public array_base<array_element<T1, T2, void, void, void, void, void, void>,
array<T1, T2>>
template<typename... T>
class array : public array_base<tuple<T...>, array<T...>>
{ {
#if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS #if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS
using array_base<array_element<T1, T2, void, void, void, void, void, void>,
array<T1, T2>>::array_base;
using array_base<tuple<T...>, array<T...>>::array_base;
#else #else
public: public:
typedef array_element<T1, T2, void, void, void, void, void, void> element_t;
typedef tuple<T...> element_t;


inline array() inline array()
: array_base<element_t,
array<T1, T2>>::array_base() {}
: array_base<element_t, array<T...>>::array_base()
{}


inline array(std::initializer_list<element_t> const &list) inline array(std::initializer_list<element_t> const &list)
: array_base<element_t,
array<T1, T2>>::array_base(list) {}
: array_base<element_t, array<T...>>::array_base(list)
{}
#endif #endif


public: public:
inline void Push(T1 const &m1, T2 const &m2)
inline void Push(T... args)
{ {
if (this->m_count >= this->m_reserved) if (this->m_count >= this->m_reserved)
{ {
T1 tmp1 = m1; T2 tmp2 = m2;
tuple<T...> tmp = { args... };
this->Grow(); this->Grow();
new (&this->m_data[this->m_count].m1) T1(tmp1);
new (&this->m_data[this->m_count].m2) T2(tmp2);
new (&this->m_data[this->m_count].m1) tuple<T...>(tmp);
} }
else else
{ {
new (&this->m_data[this->m_count].m1) T1(m1);
new (&this->m_data[this->m_count].m2) T2(m2);
new (&this->m_data[this->m_count]) tuple<T...>({ args... });
} }
++this->m_count; ++this->m_count;
} }
}; };


template<typename T> template<typename T>
class array<T, void, void, void, void, void, void, void>
: public array_base<T,
array<T>>
class array<T>
: public array_base<T, array<T>>
{ {
#if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS #if LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS
using array_base<T,
array<T>>::array_base;
using array_base<T, array<T>>::array_base;
#else #else
public: public:
typedef T element_t; typedef T element_t;


inline array() inline array()
: array_base<T,
array<T>>::array_base() {}
: array_base<T, array<T>>::array_base()
{}


inline array(std::initializer_list<element_t> const &list) inline array(std::initializer_list<element_t> const &list)
: array_base<T,
array<T>>::array_base(list) {}
: array_base<T, array<T>>::array_base(list)
{}
#endif #endif
}; };


@@ -896,32 +539,28 @@ public:
* C++11 iterators * C++11 iterators
*/ */


template<typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
typename array<T1,T2,T3,T4,T5,T6,T7,T8>::Iterator begin(array<T1,T2,T3,T4,T5,T6,T7,T8> &a)
template<typename... T>
typename array<T...>::Iterator begin(array<T...> &a)
{ {
return typename array<T1,T2,T3,T4,T5,T6,T7,T8>::Iterator(&a, 0);
return typename array<T...>::Iterator(&a, 0);
} }


template<typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
typename array<T1,T2,T3,T4,T5,T6,T7,T8>::Iterator end(array<T1,T2,T3,T4,T5,T6,T7,T8> &a)
template<typename... T>
typename array<T...>::Iterator end(array<T...> &a)
{ {
return typename array<T1,T2,T3,T4,T5,T6,T7,T8>::Iterator(&a, a.Count());
return typename array<T...>::Iterator(&a, a.Count());
} }


template<typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator begin(array<T1,T2,T3,T4,T5,T6,T7,T8> const &a)
template<typename... T>
typename array<T...>::ConstIterator begin(array<T...> const &a)
{ {
return typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator(&a, 0);
return typename array<T...>::ConstIterator(&a, 0);
} }


template<typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator end(array<T1,T2,T3,T4,T5,T6,T7,T8> const &a)
template<typename... T>
typename array<T...>::ConstIterator end(array<T...> const &a)
{ {
return typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator(&a, a.Count());
return typename array<T...>::ConstIterator(&a, a.Count());
} }


/* /*
@@ -929,10 +568,7 @@ typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator end(array<T1,T2,T3,T4,T5,
*/ */


#if LOL_FEATURE_CXX11_TEMPLATE_ALIASES #if LOL_FEATURE_CXX11_TEMPLATE_ALIASES
template<typename T1, typename T2 = void, typename T3 = void,
typename T4 = void, typename T5 = void, typename T6 = void,
typename T7 = void, typename T8 = void>
using Array = array<T1, T2, T3, T4, T5, T6, T7, T8>;
template<typename... T> using Array = array<T...>;
#else #else
# define Array array # define Array array
#endif #endif


+ 17
- 11
src/lol/base/tuple.h View File

@@ -18,15 +18,21 @@
#if !defined __LOL_BASE_TUPLE_H__ #if !defined __LOL_BASE_TUPLE_H__
#define __LOL_BASE_TUPLE_H__ #define __LOL_BASE_TUPLE_H__


#include <tuple>

#include <lol/base/assert.h> #include <lol/base/assert.h>


namespace lol namespace lol
{ {


template<typename T1, typename T2 = void, typename T3 = void,
typename T4 = void, typename T5 = void, typename T6 = void,
typename T7 = void, typename T8 = void>
class tuple
template<typename... T>
class tuple : public std::tuple<T...>
{
};

template<typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8>
class tuple<T1, T2, T3, T4, T5, T6, T7, T8>
{ {
public: public:
T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6; T7 m7; T8 m8; T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6; T7 m7; T8 m8;
@@ -34,7 +40,7 @@ public:


template<typename T1, typename T2, typename T3, typename T4, typename T5, template<typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7> typename T6, typename T7>
class tuple<T1, T2, T3, T4, T5, T6, T7, void>
class tuple<T1, T2, T3, T4, T5, T6, T7>
{ {
public: public:
T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6; T7 m7; T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6; T7 m7;
@@ -42,42 +48,42 @@ public:


template<typename T1, typename T2, typename T3, typename T4, typename T5, template<typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6> typename T6>
class tuple<T1, T2, T3, T4, T5, T6, void, void>
class tuple<T1, T2, T3, T4, T5, T6>
{ {
public: public:
T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6; T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T6 m6;
}; };


template<typename T1, typename T2, typename T3, typename T4, typename T5> template<typename T1, typename T2, typename T3, typename T4, typename T5>
class tuple<T1, T2, T3, T4, T5, void, void, void>
class tuple<T1, T2, T3, T4, T5>
{ {
public: public:
T1 m1; T2 m2; T3 m3; T4 m4; T5 m5; T1 m1; T2 m2; T3 m3; T4 m4; T5 m5;
}; };


template<typename T1, typename T2, typename T3, typename T4> template<typename T1, typename T2, typename T3, typename T4>
class tuple<T1, T2, T3, T4, void, void, void, void>
class tuple<T1, T2, T3, T4>
{ {
public: public:
T1 m1; T2 m2; T3 m3; T4 m4; T1 m1; T2 m2; T3 m3; T4 m4;
}; };


template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
class tuple<T1, T2, T3, void, void, void, void, void>
class tuple<T1, T2, T3>
{ {
public: public:
T1 m1; T2 m2; T3 m3; T1 m1; T2 m2; T3 m3;
}; };


template<typename T1, typename T2> template<typename T1, typename T2>
class tuple<T1, T2, void, void, void, void, void, void>
class tuple<T1, T2>
{ {
public: public:
T1 m1; T2 m2; T1 m1; T2 m2;
}; };


template<typename T1> template<typename T1>
class tuple<T1, void, void, void, void, void, void, void>
class tuple<T1>
{ {
public: public:
T1 m1; T1 m1;


+ 5
- 7
src/lol/math/array2d.h View File

@@ -30,13 +30,11 @@
namespace lol namespace lol
{ {


template<typename T1, typename T2 = void, typename T3 = void,
typename T4 = void, typename T5 = void, typename T6 = void,
typename T7 = void, typename T8 = void>
class array2d : protected array<T1, T2, T3, T4, T5, T6, T7, T8>
template<typename... T>
class array2d : protected array<T...>
{ {
public: public:
typedef array<T1, T2, T3, T4, T5, T6, T7, T8> super;
typedef array<T...> super;
typedef typename super::element_t element_t; typedef typename super::element_t element_t;


inline array2d() inline array2d()
@@ -111,7 +109,7 @@ public:
} }


private: private:
array2d<T1, T2, T3, T4, T5, T6, T7, T8> &m_array;
array2d<T...> &m_array;
int m_column; int m_column;
}; };


@@ -132,7 +130,7 @@ public:
} }


private: private:
array2d<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array;
array2d<T...> const &m_array;
int m_column; int m_column;
}; };




+ 7
- 9
src/lol/math/array3d.h View File

@@ -30,13 +30,11 @@
namespace lol namespace lol
{ {


template<typename T1, typename T2 = void, typename T3 = void,
typename T4 = void, typename T5 = void, typename T6 = void,
typename T7 = void, typename T8 = void>
class array3d : protected array<T1, T2, T3, T4, T5, T6, T7, T8>
template<typename... T>
class array3d : protected array<T...>
{ {
public: public:
typedef array<T1, T2, T3, T4, T5, T6, T7, T8> super;
typedef array<T...> super;
typedef typename super::element_t element_t; typedef typename super::element_t element_t;


inline array3d() inline array3d()
@@ -128,7 +126,7 @@ public:
} }


private: private:
array3d<T1, T2, T3, T4, T5, T6, T7, T8> &m_array;
array3d<T...> &m_array;
ivec2 m_line; ivec2 m_line;
}; };


@@ -140,7 +138,7 @@ public:
} }


private: private:
array3d<T1, T2, T3, T4, T5, T6, T7, T8> &m_array;
array3d<T...> &m_array;
int m_slice; int m_slice;
}; };


@@ -170,7 +168,7 @@ public:
} }


private: private:
array3d<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array;
array3d<T...> const &m_array;
ivec2 m_line; ivec2 m_line;
}; };


@@ -182,7 +180,7 @@ public:
} }


private: private:
array3d<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array;
array3d<T...> const &m_array;
int m_slice; int m_slice;
}; };




+ 3
- 5
src/lol/math/arraynd.h View File

@@ -153,13 +153,11 @@ private:
}; };




template<size_t N, typename T1, typename T2 = void, typename T3 = void,
typename T4 = void, typename T5 = void, typename T6 = void,
typename T7 = void, typename T8 = void>
class arraynd : protected array<T1, T2, T3, T4, T5, T6, T7, T8>
template<size_t N, typename... T>
class arraynd : protected array<T...>
{ {
public: public:
typedef array<T1, T2, T3, T4, T5, T6, T7, T8> super;
typedef array<T...> super;
typedef typename super::element_t element_t; typedef typename super::element_t element_t;
typedef arraynd_proxy<N, N - 1, super> proxy; typedef arraynd_proxy<N, N - 1, super> proxy;




Loading…
Cancel
Save