From: danshapero Date: Wed, 10 May 2017 02:48:58 +0000 (-0700) Subject: Added default move operations to ConstraintMatrix X-Git-Tag: v9.0.0-rc1~1608^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b5e6484c094ca10f4094628e21371b4f386aa52;p=dealii.git Added default move operations to ConstraintMatrix --- diff --git a/include/deal.II/lac/constraint_matrix.h b/include/deal.II/lac/constraint_matrix.h index 54504012b4..bea74a52d0 100644 --- a/include/deal.II/lac/constraint_matrix.h +++ b/include/deal.II/lac/constraint_matrix.h @@ -192,6 +192,16 @@ public: */ explicit ConstraintMatrix (const ConstraintMatrix &constraint_matrix); + /** + * Move constructor + */ + ConstraintMatrix (ConstraintMatrix &&constraint_matrix) = default; + + /** + * Move assignment operator + */ + ConstraintMatrix &operator= (ConstraintMatrix &&constraint_matrix) = default; + /** * clear() the ConstraintMatrix object and supply an IndexSet with lines * that may be constrained. This function is only relevant in the diff --git a/tests/lac/constraints_move.cc b/tests/lac/constraints_move.cc new file mode 100644 index 0000000000..de1fab7fba --- /dev/null +++ b/tests/lac/constraints_move.cc @@ -0,0 +1,52 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + + +#include "../tests.h" +#include +#include + +#include + +int main () +{ + std::ofstream logfile("output"); + logfile.precision(2); + + deallog.attach(logfile); + deallog.threshold_double(1.0e-10); + + ConstraintMatrix constraints; + unsigned int IDs[] = {1, 2, 3, 5, 8, 13, 21}; + double vals[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0}; + for (unsigned int i=0; i < sizeof(IDs) / sizeof(IDs[0]); ++i) + { + constraints.add_line(IDs[i]); + constraints.set_inhomogeneity(IDs[i], vals[i]); + } + + constraints.print (deallog.get_file_stream()); + deallog << std::endl; + + ConstraintMatrix cm(std::move(constraints)); + cm.print (deallog.get_file_stream()); + deallog << constraints.n_constraints() << std::endl << std::endl; + + constraints = std::move(cm); + constraints.print(deallog.get_file_stream()); + deallog << cm.n_constraints() << std::endl; + + deallog << "OK" << std::endl; +} diff --git a/tests/lac/constraints_move.output b/tests/lac/constraints_move.output new file mode 100644 index 0000000000..d44670c0ec --- /dev/null +++ b/tests/lac/constraints_move.output @@ -0,0 +1,27 @@ + + 1 = 0.0 + 2 = 1.0 + 3 = 2.0 + 5 = 3.0 + 8 = 4.0 + 13 = 5.0 + 21 = 6.0 +DEAL:: + 1 = 0.0 + 2 = 1.0 + 3 = 2.0 + 5 = 3.0 + 8 = 4.0 + 13 = 5.0 + 21 = 6.0 +DEAL::0 +DEAL:: + 1 = 0.0 + 2 = 1.0 + 3 = 2.0 + 5 = 3.0 + 8 = 4.0 + 13 = 5.0 + 21 = 6.0 +DEAL::0 +DEAL::OK