From 3a84c2a61e4acb1277a187097c95acc191cd5812 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 28 Jan 2017 22:13:36 -0500 Subject: [PATCH] Make DerivativeForm trivially copyable. We do not need to specify operator=: the default version generated by the compiler is identical. --- include/deal.II/base/derivative_form.h | 17 ----- tests/base/derivative_form_trivial_copy.cc | 69 +++++++++++++++++++ .../base/derivative_form_trivial_copy.output | 21 ++++++ 3 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 tests/base/derivative_form_trivial_copy.cc create mode 100644 tests/base/derivative_form_trivial_copy.output diff --git a/include/deal.II/base/derivative_form.h b/include/deal.II/base/derivative_form.h index 39e07b1249..de695e72d9 100644 --- a/include/deal.II/base/derivative_form.h +++ b/include/deal.II/base/derivative_form.h @@ -76,11 +76,6 @@ public: */ const Tensor &operator [] (const unsigned int i) const; - /** - * Assignment operator. - */ - DerivativeForm &operator = (const DerivativeForm &); - /** * Assignment operator. */ @@ -191,18 +186,6 @@ DerivativeForm::DerivativeForm(const Tensor -inline -DerivativeForm & -DerivativeForm:: -operator = (const DerivativeForm &ta) -{ - for (unsigned int j=0; j inline diff --git a/tests/base/derivative_form_trivial_copy.cc b/tests/base/derivative_form_trivial_copy.cc new file mode 100644 index 0000000000..09b4e2242f --- /dev/null +++ b/tests/base/derivative_form_trivial_copy.cc @@ -0,0 +1,69 @@ +// --------------------------------------------------------------------- +// +// 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 DerivativeForm 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 << "DerivativeForm<1, 2, 2> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; + deallog << "DerivativeForm<2, 2, 2> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; + deallog << "DerivativeForm<2, 2, 3> is trivially copyable: " + << boost::has_trivial_copy >::value + << std::endl; + deallog << "DerivativeForm<2, 3, 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/derivative_form_trivial_copy.output b/tests/base/derivative_form_trivial_copy.output new file mode 100644 index 0000000000..494bb3e662 --- /dev/null +++ b/tests/base/derivative_form_trivial_copy.output @@ -0,0 +1,21 @@ + +DEAL::testing float +DEAL::DerivativeForm<1, 2, 2> is trivially copyable: true +DEAL::DerivativeForm<2, 2, 2> is trivially copyable: true +DEAL::DerivativeForm<2, 2, 3> is trivially copyable: true +DEAL::DerivativeForm<2, 3, 3> is trivially copyable: true +DEAL::testing double +DEAL::DerivativeForm<1, 2, 2> is trivially copyable: true +DEAL::DerivativeForm<2, 2, 2> is trivially copyable: true +DEAL::DerivativeForm<2, 2, 3> is trivially copyable: true +DEAL::DerivativeForm<2, 3, 3> is trivially copyable: true +DEAL::testing std::complex +DEAL::DerivativeForm<1, 2, 2> is trivially copyable: true +DEAL::DerivativeForm<2, 2, 2> is trivially copyable: true +DEAL::DerivativeForm<2, 2, 3> is trivially copyable: true +DEAL::DerivativeForm<2, 3, 3> is trivially copyable: true +DEAL::testing std::complex +DEAL::DerivativeForm<1, 2, 2> is trivially copyable: true +DEAL::DerivativeForm<2, 2, 2> is trivially copyable: true +DEAL::DerivativeForm<2, 2, 3> is trivially copyable: true +DEAL::DerivativeForm<2, 3, 3> is trivially copyable: true -- 2.39.5