From 7462136e9cc154c58a29fcf6e1b60ce6d2f36b65 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Fri, 11 Sep 2015 20:58:57 -0500 Subject: [PATCH] Tensor - use TensorAccessors::extract Remove special internal code and use the generic implementation in TensorAccessors::extract. --- include/deal.II/base/tensor.h | 59 +++-------------------------------- 1 file changed, 5 insertions(+), 54 deletions(-) diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index cb1de1852c..7d231bc49d 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -785,56 +786,6 @@ void Tensor<0,dim,Number>::serialize(Archive &ar, const unsigned int) /*-------------------- Inline functions: Tensor --------------------*/ -namespace internal -{ - // TODO: Think about refactoring this into the TableIndices class as a - // general, polymorphic for extracting an item out of an object with - // nested identifiers. - template struct TensorIndicesHelper - { - // used for implementing Tensor::operator[] with TableIndices - // tail recursive call to form up access to - // tensor[indices[0]][indices[1]]...[indices[rank_]] - template - static inline - Number &extract(Tensor &t, const TableIndices &indices) - { - Assert (indices[rank - rank_]::template extract( - t[indices[rank - rank_]], indices); - } - - template - static inline - const Number &extract(const Tensor &t, const TableIndices &indices) - { - Assert (indices[rank - rank_]::template extract( - t[indices[rank - rank_]], indices); - } - }; - - template<> struct TensorIndicesHelper<1> - { - template - static inline - Number &extract(Tensor<1,dim,Number> &t, const TableIndices &indices) - { - Assert (indices[rank - 1] - static inline - const Number &extract(const Tensor<1,dim,Number> &t, const TableIndices &indices) - { - Assert (indices[rank - 1] inline Tensor::Tensor () @@ -947,8 +898,8 @@ Number Tensor::operator[] (const TableIndices &indices) const { Assert(dim != 0, ExcMessage("Cannot access an object of type Tensor")); - Assert (indices[0]::template extract(*this, indices); + + return TensorAccessors::extract(*this, indices); } @@ -958,8 +909,8 @@ Number & Tensor::operator[] (const TableIndices &indices) { Assert(dim != 0, ExcMessage("Cannot access an object of type Tensor")); - Assert (indices[0]::template extract(*this, indices); + + return TensorAccessors::extract(*this, indices); } -- 2.39.5