]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make DerivativeForm trivially copyable. 3867/head
authorDavid Wells <wellsd2@rpi.edu>
Sun, 29 Jan 2017 03:13:36 +0000 (22:13 -0500)
committerDavid Wells <wellsd2@rpi.edu>
Sun, 29 Jan 2017 03:16:53 +0000 (22:16 -0500)
We do not need to specify operator=: the default version generated by
the compiler is identical.

include/deal.II/base/derivative_form.h
tests/base/derivative_form_trivial_copy.cc [new file with mode: 0644]
tests/base/derivative_form_trivial_copy.output [new file with mode: 0644]

index 39e07b1249d461f45e5918c05d889a374bb8fe07..de695e72d927662d63cb0bf2875ed3a050e941ab 100644 (file)
@@ -76,11 +76,6 @@ public:
    */
   const Tensor<order,dim,Number> &operator [] (const unsigned int i) const;
 
-  /**
-   * Assignment operator.
-   */
-  DerivativeForm   &operator = (const DerivativeForm <order, dim, spacedim, Number> &);
-
   /**
    * Assignment operator.
    */
@@ -191,18 +186,6 @@ DerivativeForm<order, dim, spacedim, Number>::DerivativeForm(const Tensor<order+
 
 
 
-template <int order, int dim, int spacedim, typename Number>
-inline
-DerivativeForm<order, dim, spacedim, Number> &
-DerivativeForm<order, dim, spacedim, Number>::
-operator = (const DerivativeForm<order, dim, spacedim, Number> &ta)
-{
-  for (unsigned int j=0; j<spacedim; ++j)
-    (*this)[j] = ta[j];
-  return *this;
-}
-
-
 
 template <int order, int dim, int spacedim, typename Number>
 inline
diff --git a/tests/base/derivative_form_trivial_copy.cc b/tests/base/derivative_form_trivial_copy.cc
new file mode 100644 (file)
index 0000000..09b4e22
--- /dev/null
@@ -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 <deal.II/base/derivative_form.h>
+
+#include <boost/type_traits.hpp>
+
+#include <complex>
+
+#include "../tests.h"
+
+template <typename Number>
+void test()
+{
+  deallog << "DerivativeForm<1, 2, 2> is trivially copyable: "
+          << boost::has_trivial_copy<DerivativeForm<1, 2, 2, Number> >::value
+          << std::endl;
+  deallog << "DerivativeForm<2, 2, 2> is trivially copyable: "
+          << boost::has_trivial_copy<DerivativeForm<2, 2, 2, Number> >::value
+          << std::endl;
+  deallog << "DerivativeForm<2, 2, 3> is trivially copyable: "
+          << boost::has_trivial_copy<DerivativeForm<2, 2, 3, Number> >::value
+          << std::endl;
+  deallog << "DerivativeForm<2, 3, 3> is trivially copyable: "
+          << boost::has_trivial_copy<DerivativeForm<2, 3, 3, Number> >::value
+          << std::endl;
+}
+
+int main()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+
+  deallog << std::boolalpha;
+  deallog << "testing float"
+          << std::endl;
+  test<float>();
+
+  deallog << "testing double"
+          << std::endl;
+  test<double>();
+
+  deallog << "testing std::complex<float>"
+          << std::endl;
+  test<std::complex<float> >();
+
+  deallog << "testing std::complex<double>"
+          << std::endl;
+  test<std::complex<double> >();
+}
diff --git a/tests/base/derivative_form_trivial_copy.output b/tests/base/derivative_form_trivial_copy.output
new file mode 100644 (file)
index 0000000..494bb3e
--- /dev/null
@@ -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<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 std::complex<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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.