]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Wrote move assignment operator for Triangulation, Subscriptor throws exception in...
authordanshapero <shapero.daniel@gmail.com>
Mon, 29 Aug 2016 18:42:23 +0000 (11:42 -0700)
committerdanshapero <shapero.daniel@gmail.com>
Mon, 19 Sep 2016 00:26:02 +0000 (17:26 -0700)
include/deal.II/grid/tria.h
source/grid/tria.cc
tests/grid/move_constructor.cc
tests/grid/move_constructor.with_cxx11=on.output

index 224d70830ebf769fb5e925e289d8534a7cc706c4..421ff17e86f931daa43c33999558b7c286950ce6 100644 (file)
@@ -1530,6 +1530,11 @@ public:
    * triangulation.
    */
   Triangulation (Triangulation<dim, spacedim> &&tria);
+
+  /**
+   * Move assignment operator.
+   */
+  Triangulation &operator = (Triangulation<dim, spacedim> &&tria);
 #endif
 
   /**
index 9dd232f83454ce3212ad00eb49148d99e1e12440..a98dfad2abafc3d661197dcd46f599e68013eb6d 100644 (file)
@@ -9015,6 +9015,35 @@ Triangulation (Triangulation<dim, spacedim> &&tria)
 
   tria.number_cache = internal::Triangulation::NumberCache<dim>();
 }
+
+
+template <int dim, int spacedim>
+Triangulation<dim, spacedim>&
+Triangulation<dim, spacedim>::operator= (Triangulation<dim, spacedim> &&tria)
+{
+  Subscriptor::operator=(std::move(tria));
+
+  smooth_grid = tria.smooth_grid;
+  periodic_face_pairs_level_0 = std::move(tria.periodic_face_pairs_level_0);
+  periodic_face_map = std::move(tria.periodic_face_map);
+  levels = std::move(tria.levels);
+  faces = std::move(tria.faces);
+  vertices = std::move(tria.vertices);
+  vertices_used = std::move(tria.vertices_used);
+  manifold = std::move(tria.manifold);
+  anisotropic_refinement = tria.anisotropic_refinement;
+  //check_for_distorted_cells = tria.check_for_distorted_cells;
+  number_cache = tria.number_cache;
+  vertex_to_boundary_id_map_1d = std::move(tria.vertex_to_boundary_id_map_1d);
+  vertex_to_manifold_id_map_1d = std::move(tria.vertex_to_manifold_id_map_1d);
+
+  for (unsigned int i=0; i<tria.levels.size(); ++i)
+    tria.levels[i] = nullptr;
+
+  tria.number_cache = internal::Triangulation::NumberCache<dim>();
+
+  return *this;
+}
 #endif
 
 
index b272e74a62811054631e396ebe35822cbacac4c4..724bd9c81857dfc6cc5f280a05e6d76967c603ef 100644 (file)
@@ -55,6 +55,10 @@ void test_hyper_cube()
   Triangulation<dim> new_tria = std::move(tria);
   print_tria_info(new_tria);
   print_tria_info(tria);
+
+  tria = std::move(new_tria);
+  print_tria_info(new_tria);
+  print_tria_info(tria);
 }
 
 
@@ -76,6 +80,10 @@ void test_hyper_shell()
   Triangulation<dim> new_tria = std::move(tria);
   print_tria_info(new_tria);
   print_tria_info(tria);
+
+  tria = std::move(new_tria);
+  print_tria_info(new_tria);
+  print_tria_info(tria);
 }
 
 
@@ -98,6 +106,10 @@ void test_periodic_cube()
   Triangulation<dim> new_tria = std::move(tria);
   print_tria_info(new_tria);
   print_tria_info(tria);
+
+  tria = std::move(new_tria);
+  print_tria_info(new_tria);
+  print_tria_info(tria);
 }
 
 
index 76860e1bb0c102e55fe7c082ca04257c7de7fecc..0b68a9dcefc1f6591f104174b03733172e93bbe2 100644 (file)
@@ -4,27 +4,39 @@ DEAL::Dimension: 2
 DEAL::1, 0, 1, 1, 1, 1, 0, 1
 DEAL::1, 0, 1, 1, 1, 1, 0, 1
 DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::1, 0, 1, 1, 1, 1, 0, 1
 DEAL::Dimension: 3
 DEAL::1, 1, 1, 1, 1, 1, 0, 1
 DEAL::1, 1, 1, 1, 1, 1, 0, 1
 DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::1, 1, 1, 1, 1, 1, 0, 1
 DEAL::
 DEAL::Hyper-shell:
 DEAL::Dimension: 2
 DEAL::1, 0, 1, 1, 1, 1, 0, 0
 DEAL::1, 0, 1, 1, 1, 1, 0, 0
 DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::1, 0, 1, 1, 1, 1, 0, 0
 DEAL::Dimension: 3
 DEAL::1, 1, 1, 1, 1, 1, 0, 0
 DEAL::1, 1, 1, 1, 1, 1, 0, 0
 DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::1, 1, 1, 1, 1, 1, 0, 0
 DEAL::
 DEAL::Periodic hyper-cube:
 DEAL::Dimension: 2
 DEAL::1, 0, 1, 1, 1, 1, 1, 1
 DEAL::1, 0, 1, 1, 1, 1, 1, 1
 DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::1, 0, 1, 1, 1, 1, 1, 1
 DEAL::Dimension: 3
 DEAL::1, 1, 1, 1, 1, 1, 1, 1
 DEAL::1, 1, 1, 1, 1, 1, 1, 1
 DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::0, 0, 0, 0, 0, 0, 0, 1
+DEAL::1, 1, 1, 1, 1, 1, 1, 1

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.