From: Sebastian Proell Date: Fri, 3 Mar 2023 14:42:06 +0000 (+0100) Subject: SymmetricTensor access returns const reference X-Git-Tag: v9.5.0-rc1~511^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5d8ddf6be0945cf108e2e36360fe7bffadef10a;p=dealii.git SymmetricTensor access returns const reference --- diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 4a8397a6d0..9ba9418450 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -421,7 +421,7 @@ namespace internal { using tensor_type = const ::dealii::SymmetricTensor; - using reference = Number; + using reference = const Number &; }; /** diff --git a/tests/tensors/symmetric_tensor_46.cc b/tests/tensors/symmetric_tensor_46.cc new file mode 100644 index 0000000000..a361211ae9 --- /dev/null +++ b/tests/tensors/symmetric_tensor_46.cc @@ -0,0 +1,43 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2023 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Test that a const SymmetricTensor is not assignable, i.e., the accessors +// return a const reference + +#include +#include +#include + +#include "../tests.h" + +int +main() +{ + initlog(); + + { + const SymmetricTensor<2, 3, double> st{}; + static_assert(std::is_same::value); + } + + { + const SymmetricTensor<2, 3, VectorizedArray> stv{}; + static_assert(std::is_same &>::value); + } + + deallog << "OK" << std::endl; +} diff --git a/tests/tensors/symmetric_tensor_46.output b/tests/tensors/symmetric_tensor_46.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/tensors/symmetric_tensor_46.output @@ -0,0 +1,2 @@ + +DEAL::OK