From: David Wells Date: Sat, 11 Nov 2023 16:04:48 +0000 (-0500) Subject: SymmetricTensor: use if constexpr() to get rid of a function. X-Git-Tag: relicensing~304^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5668324eefa01da966b6af42e2383e1ecf9da30f;p=dealii.git SymmetricTensor: use if constexpr() to get rid of a function. --- diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index fa61cdf567..89ad3b399a 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -2333,41 +2333,16 @@ SymmetricTensor::end_raw() const -namespace internal -{ - namespace SymmetricTensorImplementation - { - template - constexpr unsigned int - entry_to_indices(const dealii::SymmetricTensor<2, dim, Number> &, - const unsigned int index) - { - return index; - } - - - template - constexpr dealii::TableIndices<2> - entry_to_indices(const dealii::SymmetricTensor<4, dim, Number> &, - const unsigned int index) - { - return internal::SymmetricTensorAccessors::StorageType<4, dim, Number>:: - base_tensor_type::unrolled_to_component_indices(index); - } - - } // namespace SymmetricTensorImplementation -} // namespace internal - - - template DEAL_II_HOST constexpr inline const Number & SymmetricTensor::access_raw_entry( const unsigned int index) const { AssertIndexRange(index, n_independent_components); - return data[internal::SymmetricTensorImplementation::entry_to_indices(*this, - index)]; + if constexpr (rank == 2) + return data[index]; + else + return data[decltype(data)::unrolled_to_component_indices(index)]; } @@ -2377,8 +2352,10 @@ DEAL_II_HOST constexpr inline Number & SymmetricTensor::access_raw_entry(const unsigned int index) { AssertIndexRange(index, n_independent_components); - return data[internal::SymmetricTensorImplementation::entry_to_indices(*this, - index)]; + if constexpr (rank == 2) + return data[index]; + else + return data[decltype(data)::unrolled_to_component_indices(index)]; }