]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Clean up some code with std_cxx14::make_unique. 4238/head
authorDavid Wells <wellsd2@rpi.edu>
Sat, 8 Apr 2017 21:57:57 +0000 (17:57 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Sun, 9 Apr 2017 23:20:46 +0000 (19:20 -0400)
source/numerics/data_out_dof_data.cc

index e767e33cc092f6a79ec13be75cf2ffd36eb8cf4b..abac0f9b42e3255fa411bf3ad4606752ebd3de59 100644 (file)
@@ -16,6 +16,7 @@
 #include <deal.II/base/quadrature_lib.h>
 #include <deal.II/base/work_stream.h>
 #include <deal.II/base/memory_consumption.h>
+#include <deal.II/base/std_cxx14/memory.h>
 #include <deal.II/lac/vector.h>
 #include <deal.II/lac/block_vector.h>
 #include <deal.II/lac/la_vector.h>
@@ -986,13 +987,13 @@ add_data_vector (const VectorType                         &vec,
       Assert (false, ExcInternalError());
     }
 
-  internal::DataOut::DataEntryBase<DoFHandlerType> *new_entry
-    = new internal::DataOut::DataEntry<DoFHandlerType,VectorType>(dofs, &vec, names,
-        data_component_interpretation);
+  auto new_entry = std_cxx14::make_unique<internal::DataOut::DataEntry<DoFHandlerType,VectorType>>
+                   (dofs, &vec, names, data_component_interpretation);
+
   if (actual_type == type_dof_data)
-    dof_data.push_back (std::shared_ptr<internal::DataOut::DataEntryBase<DoFHandlerType> >(new_entry));
+    dof_data.emplace_back (std::move(new_entry));
   else
-    cell_data.push_back (std::shared_ptr<internal::DataOut::DataEntryBase<DoFHandlerType> >(new_entry));
+    cell_data.emplace_back (std::move(new_entry));
 }
 
 
@@ -1018,9 +1019,9 @@ add_data_vector (const VectorType                       &vec,
                                                      dofs->n_dofs(),
                                                      dofs->get_triangulation().n_active_cells()));
 
-  internal::DataOut::DataEntryBase<DoFHandlerType> *new_entry
-    = new internal::DataOut::DataEntry<DoFHandlerType,VectorType>(dofs, &vec, &data_postprocessor);
-  dof_data.push_back (std::shared_ptr<internal::DataOut::DataEntryBase<DoFHandlerType> >(new_entry));
+  auto new_entry = std_cxx14::make_unique<internal::DataOut::DataEntry<DoFHandlerType,VectorType>>
+                   (dofs, &vec, &data_postprocessor);
+  dof_data.emplace_back (std::move(new_entry));
 }
 
 
@@ -1041,9 +1042,9 @@ add_data_vector (const DoFHandlerType                   &dof_handler,
 
   AssertDimension (vec.size(), dof_handler.n_dofs());
 
-  internal::DataOut::DataEntryBase<DoFHandlerType> *new_entry
-    = new internal::DataOut::DataEntry<DoFHandlerType,VectorType>(&dof_handler, &vec, &data_postprocessor);
-  dof_data.push_back (std::shared_ptr<internal::DataOut::DataEntryBase<DoFHandlerType> >(new_entry));
+  auto new_entry = std_cxx14::make_unique<internal::DataOut::DataEntry<DoFHandlerType,VectorType>>
+                   (&dof_handler, &vec, &data_postprocessor);
+  dof_data.emplace_back (std::move(new_entry));
 }
 
 
@@ -1118,10 +1119,9 @@ add_data_vector
        std::vector<DataComponentInterpretation::DataComponentInterpretation>
        (names.size(), DataComponentInterpretation::component_is_scalar));
 
-  internal::DataOut::DataEntryBase<DoFHandlerType> *new_entry
-    = new internal::DataOut::DataEntry<DoFHandlerType,VectorType>(&dof_handler, &data, names,
-        data_component_interpretation);
-  dof_data.push_back (std::shared_ptr<internal::DataOut::DataEntryBase<DoFHandlerType> >(new_entry));
+  auto new_entry = std_cxx14::make_unique<internal::DataOut::DataEntry<DoFHandlerType,VectorType>>
+                   (&dof_handler, &data, names, data_component_interpretation);
+  dof_data.emplace_back (std::move(new_entry));
 }
 
 

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.