From 1b784d3a242cbb251ca4729ae30017f98a960be0 Mon Sep 17 00:00:00 2001 From: Guillaume Bittoun Date: Thu, 10 Jul 2014 14:04:30 +0000 Subject: [PATCH] =?UTF-8?q?arraynd:=20templating=20proxy=E2=80=99s=20inner?= =?UTF-8?q?=20array=20type=20instead=20of=20specializing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lol/math/arraynd.h | 235 ++--------------------------------------- 1 file changed, 10 insertions(+), 225 deletions(-) diff --git a/src/lol/math/arraynd.h b/src/lol/math/arraynd.h index 90968370..0348a83d 100644 --- a/src/lol/math/arraynd.h +++ b/src/lol/math/arraynd.h @@ -29,17 +29,14 @@ namespace lol { -template +template class arraynd_proxy { public: - typedef array array_type; - typedef arraynd_proxy subproxy; + typedef arraynd_proxy subproxy; - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : + inline arraynd_proxy(ARRAY_TYPE * array, vec_t const & sizes, size_t index, size_t accumulator) : m_array(array), m_sizes(sizes), m_index(index), @@ -54,231 +51,19 @@ public: private: - array_type * m_array; - vec_t const & m_sizes; - size_t m_index; - size_t m_accumulator; -}; - - -template -class arraynd_proxy -{ -public: - - typedef array array_type; - - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : - m_array(array), - m_sizes(sizes), - m_index(index), - m_accumulator(accumulator) - { - } - - inline typename array_type::element_t & operator[](size_t pos) - { - return m_array[m_index + pos * m_accumulator]; - } - -private: - - array_type * m_array; - vec_t const & m_sizes; - size_t m_index; - size_t m_accumulator; -}; - - -template -class arraynd_proxy -{ -public: - - typedef array array_type; - - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : - m_array(array), - m_sizes(sizes), - m_index(index), - m_accumulator(accumulator) - { - } - - inline typename array_type::element_t & operator[](size_t pos) - { - return m_array[m_index + pos * m_accumulator]; - } - -private: - - array_type * m_array; - vec_t const & m_sizes; - size_t m_index; - size_t m_accumulator; -}; - - -template -class arraynd_proxy -{ -public: - - typedef array array_type; - - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : - m_array(array), - m_sizes(sizes), - m_index(index), - m_accumulator(accumulator) - { - } - - inline typename array_type::element_t & operator[](size_t pos) - { - return m_array[m_index + pos * m_accumulator]; - } - -private: - - array_type * m_array; - vec_t const & m_sizes; - size_t m_index; - size_t m_accumulator; -}; - - -template -class arraynd_proxy -{ -public: - - typedef array array_type; - - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : - m_array(array), - m_sizes(sizes), - m_index(index), - m_accumulator(accumulator) - { - } - - inline typename array_type::element_t & operator[](size_t pos) - { - return m_array[m_index + pos * m_accumulator]; - } - -private: - - array_type * m_array; - vec_t const & m_sizes; - size_t m_index; - size_t m_accumulator; -}; - - -template -class arraynd_proxy -{ -public: - - typedef array array_type; - - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : - m_array(array), - m_sizes(sizes), - m_index(index), - m_accumulator(accumulator) - { - } - - inline typename array_type::element_t & operator[](size_t pos) - { - return m_array[m_index + pos * m_accumulator]; - } - -private: - - array_type * m_array; - vec_t const & m_sizes; - size_t m_index; - size_t m_accumulator; -}; - - -template -class arraynd_proxy -{ -public: - - typedef array array_type; - - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : - m_array(array), - m_sizes(sizes), - m_index(index), - m_accumulator(accumulator) - { - } - - inline typename array_type::element_t & operator[](size_t pos) - { - return m_array[m_index + pos * m_accumulator]; - } - -private: - - array_type * m_array; + ARRAY_TYPE * m_array; vec_t const & m_sizes; size_t m_index; size_t m_accumulator; }; -template -class arraynd_proxy +template +class arraynd_proxy { public: - typedef array array_type; - - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : - m_array(array), - m_sizes(sizes), - m_index(index), - m_accumulator(accumulator) - { - } - - inline typename array_type::element_t & operator[](size_t pos) - { - return m_array[m_index + pos * m_accumulator]; - } - -private: - - array_type * m_array; - vec_t const & m_sizes; - size_t m_index; - size_t m_accumulator; -}; - - -template -class arraynd_proxy -{ -public: - - typedef array array_type; - - inline arraynd_proxy(array_type * array, vec_t const & sizes, size_t index, size_t accumulator) : + inline arraynd_proxy(ARRAY_TYPE * array, vec_t const & sizes, size_t index, size_t accumulator) : m_array(array), m_sizes(sizes), m_index(index), @@ -286,14 +71,14 @@ public: { } - inline typename array_type::element_t & operator[](size_t pos) + inline typename ARRAY_TYPE::element_t & operator[](size_t pos) { return m_array[m_index + pos * m_accumulator]; } private: - array_type * m_array; + ARRAY_TYPE * m_array; vec_t const & m_sizes; size_t m_index; size_t m_accumulator; @@ -308,7 +93,7 @@ class arraynd : protected array public: typedef array super; typedef typename super::element_t element_t; - typedef arraynd_proxy proxy; + typedef arraynd_proxy proxy; inline arraynd() : super(),