]> https://gitweb.dealii.org/ - dealii.git/commitdiff
step-28: Convert raw pointers to unique_ptrs.
authorDavid Wells <drwells@email.unc.edu>
Tue, 7 May 2019 00:29:37 +0000 (20:29 -0400)
committerDavid Wells <drwells@email.unc.edu>
Tue, 7 May 2019 02:34:55 +0000 (22:34 -0400)
examples/step-28/step-28.cc

index b45df6eb6a3ad1b1668ac34f624825f8d3751b5f..171a0b385a1004dfc5c4da1efee133d4c3232d4a 100644 (file)
@@ -1165,10 +1165,7 @@ namespace Step28
       double convergence_tolerance;
     };
 
-
-
     NeutronDiffusionProblem(const Parameters &parameters);
-    ~NeutronDiffusionProblem();
 
     void run();
 
@@ -1209,7 +1206,7 @@ namespace Step28
     // Finally, (v), we have an array of pointers to the energy group
     // objects. The length of this array is, of course, equal to the number of
     // energy groups specified in the parameter file.
-    std::vector<EnergyGroup<dim> *> energy_groups;
+    std::vector<std::unique_ptr<EnergyGroup<dim>>> energy_groups;
   };
 
 
@@ -1283,15 +1280,6 @@ namespace Step28
 
 
 
-  template <int dim>
-  NeutronDiffusionProblem<dim>::~NeutronDiffusionProblem()
-  {
-    for (unsigned int group = 0; group < energy_groups.size(); ++group)
-      delete energy_groups[group];
-
-    energy_groups.resize(0);
-  }
-
   // @sect5{<code>NeutronDiffusionProblem::initialize_problem</code>}
   //
   // The first function of interest is the one that sets up the geometry of
@@ -1466,10 +1454,9 @@ namespace Step28
     // With the coarse mesh so initialized, we create the appropriate number
     // of energy group objects and let them initialize their individual meshes
     // with the coarse mesh generated above:
-    energy_groups.resize(parameters.n_groups);
     for (unsigned int group = 0; group < parameters.n_groups; ++group)
-      energy_groups[group] =
-        new EnergyGroup<dim>(group, material_data, coarse_grid, fe);
+      energy_groups.emplace_back(std_cxx14::make_unique<EnergyGroup<dim>>(
+        group, material_data, coarse_grid, fe));
   }
 
 

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.