From: Matthias Maier Date: Sat, 12 Sep 2015 01:58:57 +0000 (-0500) Subject: Tensor - use TensorAccessors::extract X-Git-Tag: v8.4.0-rc2~433^2~9 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7462136e9cc154c58a29fcf6e1b60ce6d2f36b65;p=dealii.git Tensor - use TensorAccessors::extract Remove special internal code and use the generic implementation in TensorAccessors::extract. --- 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); }