From 80be3b722224ee34b461b91828238c68e1de21eb Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 15 Jan 2017 23:44:42 -0500 Subject: [PATCH] Make SymmetricTensor trivially copyable. This is a follow up to 0004f1cbcd2 which made Tensors trivially copyable. --- include/deal.II/base/symmetric_tensor.h | 16 ---- tests/base/symmetric_tensor_trivial_copy.cc | 76 +++++++++++++++++++ .../base/symmetric_tensor_trivial_copy.output | 29 +++++++ 3 files changed, 105 insertions(+), 16 deletions(-) create mode 100644 tests/base/symmetric_tensor_trivial_copy.cc create mode 100644 tests/base/symmetric_tensor_trivial_copy.output diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 86fd420cfd..2a5b4c16fa 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -569,11 +569,6 @@ public: explicit SymmetricTensor (const SymmetricTensor &initializer); - /** - * Assignment operator. - */ - SymmetricTensor &operator = (const SymmetricTensor &); - /** * This operator assigns a scalar to a tensor. To avoid confusion with what * exactly it means to assign a scalar value to a tensor, zero is the only @@ -1005,17 +1000,6 @@ SymmetricTensor::SymmetricTensor (const Number (&array) [n_inde -template -inline -SymmetricTensor & -SymmetricTensor::operator = (const SymmetricTensor &t) -{ - data = t.data; - return *this; -} - - - template inline SymmetricTensor & diff --git a/tests/base/symmetric_tensor_trivial_copy.cc b/tests/base/symmetric_tensor_trivial_copy.cc new file mode 100644 index 0000000000..1f0027202a --- /dev/null +++ b/tests/base/symmetric_tensor_trivial_copy.cc @@ -0,0 +1,76 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// Verify that SymmetricTensor is trivially copyable. + +// TODO not all compilers that support enough of a subset of C++11 to compile +// the library (notably GCC 4.8) implement std::is_trivally_copyable. At some +// point in the future we should use that instead of the boost equivalent. + +#include + +#include + +#include + +#include "../tests.h" + +template +void test() +{ + deallog << "SymmetricTensor<2, 1> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; + deallog << "SymmetricTensor<2, 2> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; + deallog << "SymmetricTensor<2, 3> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; + + deallog << "SymmetricTensor<4, 1> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; + deallog << "SymmetricTensor<4, 2> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; + deallog << "SymmetricTensor<4, 3> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; +} + +int main() +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + + deallog << std::boolalpha; + deallog << "testing float" + << std::endl; + test(); + + deallog << "testing double" + << std::endl; + test(); + + deallog << "testing std::complex" + << std::endl; + test >(); + + deallog << "testing std::complex" + << std::endl; + test >(); +} diff --git a/tests/base/symmetric_tensor_trivial_copy.output b/tests/base/symmetric_tensor_trivial_copy.output new file mode 100644 index 0000000000..35a9731eb6 --- /dev/null +++ b/tests/base/symmetric_tensor_trivial_copy.output @@ -0,0 +1,29 @@ + +DEAL::testing float +DEAL::SymmetricTensor<2, 1> is trivially copyable: true +DEAL::SymmetricTensor<2, 2> is trivially copyable: true +DEAL::SymmetricTensor<2, 3> is trivially copyable: true +DEAL::SymmetricTensor<4, 1> is trivially copyable: true +DEAL::SymmetricTensor<4, 2> is trivially copyable: true +DEAL::SymmetricTensor<4, 3> is trivially copyable: true +DEAL::testing double +DEAL::SymmetricTensor<2, 1> is trivially copyable: true +DEAL::SymmetricTensor<2, 2> is trivially copyable: true +DEAL::SymmetricTensor<2, 3> is trivially copyable: true +DEAL::SymmetricTensor<4, 1> is trivially copyable: true +DEAL::SymmetricTensor<4, 2> is trivially copyable: true +DEAL::SymmetricTensor<4, 3> is trivially copyable: true +DEAL::testing std::complex +DEAL::SymmetricTensor<2, 1> is trivially copyable: true +DEAL::SymmetricTensor<2, 2> is trivially copyable: true +DEAL::SymmetricTensor<2, 3> is trivially copyable: true +DEAL::SymmetricTensor<4, 1> is trivially copyable: true +DEAL::SymmetricTensor<4, 2> is trivially copyable: true +DEAL::SymmetricTensor<4, 3> is trivially copyable: true +DEAL::testing std::complex +DEAL::SymmetricTensor<2, 1> is trivially copyable: true +DEAL::SymmetricTensor<2, 2> is trivially copyable: true +DEAL::SymmetricTensor<2, 3> is trivially copyable: true +DEAL::SymmetricTensor<4, 1> is trivially copyable: true +DEAL::SymmetricTensor<4, 2> is trivially copyable: true +DEAL::SymmetricTensor<4, 3> is trivially copyable: true -- 2.39.5