From e29ddd57e10a226698876af4375418b2dfde2b74 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 22 Feb 2018 04:25:22 +0100 Subject: [PATCH] Fix findings of "modernize-use-emplace" --- cmake/scripts/expand_instantiations.cc | 3 +-- examples/step-19/step-19.cc | 2 +- examples/step-20/step-20.cc | 2 +- examples/step-21/step-21.cc | 18 +++++++++--------- examples/step-22/step-22.cc | 2 +- examples/step-29/step-29.cc | 4 ++-- examples/step-34/step-34.cc | 6 +++--- examples/step-35/step-35.cc | 4 ++-- examples/step-44/step-44.cc | 4 ++-- examples/step-46/step-46.cc | 4 ++-- examples/step-47/step-47.cc | 2 +- examples/step-51/step-51.cc | 2 +- examples/step-56/step-56.cc | 2 +- examples/step-57/step-57.cc | 2 +- examples/step-7/step-7.cc | 6 +++--- examples/step-8/step-8.cc | 12 ++++++------ tests/quick_tests/nanoflann.cc | 14 +++++++------- 17 files changed, 44 insertions(+), 45 deletions(-) diff --git a/cmake/scripts/expand_instantiations.cc b/cmake/scripts/expand_instantiations.cc index 2dc0f5f8ed..43906404e0 100644 --- a/cmake/scripts/expand_instantiations.cc +++ b/cmake/scripts/expand_instantiations.cc @@ -493,8 +493,7 @@ void process_instantiations () for (std::list::const_iterator x = names.begin(); x != names.end(); ++x) - substitutions.push_back (std::make_pair (*x, - names_and_type.back())); + substitutions.emplace_back (*x, names_and_type.back()); } // now read the part in {...} diff --git a/examples/step-19/step-19.cc b/examples/step-19/step-19.cc index da7008917a..491007c2fd 100644 --- a/examples/step-19/step-19.cc +++ b/examples/step-19/step-19.cc @@ -245,7 +245,7 @@ namespace Step19 // the name of the executable at the zeroth index: std::list args; for (int i=1; i-p, // then there must be a parameter file following (which we should then diff --git a/examples/step-20/step-20.cc b/examples/step-20/step-20.cc index 64361a5f3f..142b767191 100644 --- a/examples/step-20/step-20.cc +++ b/examples/step-20/step-20.cc @@ -867,7 +867,7 @@ namespace Step20 void MixedLaplaceProblem::output_results () const { std::vector solution_names(dim, "u"); - solution_names.push_back ("p"); + solution_names.emplace_back("p"); std::vector interpretation (dim, DataComponentInterpretation::component_is_part_of_vector); diff --git a/examples/step-21/step-21.cc b/examples/step-21/step-21.cc index 145a3ae3ef..4b9e03b671 100644 --- a/examples/step-21/step-21.cc +++ b/examples/step-21/step-21.cc @@ -1103,18 +1103,18 @@ namespace Step21 switch (dim) { case 2: - solution_names.push_back ("u"); - solution_names.push_back ("v"); - solution_names.push_back ("p"); - solution_names.push_back ("S"); + solution_names.emplace_back("u"); + solution_names.emplace_back("v"); + solution_names.emplace_back("p"); + solution_names.emplace_back("S"); break; case 3: - solution_names.push_back ("u"); - solution_names.push_back ("v"); - solution_names.push_back ("w"); - solution_names.push_back ("p"); - solution_names.push_back ("S"); + solution_names.emplace_back("u"); + solution_names.emplace_back("v"); + solution_names.emplace_back("w"); + solution_names.emplace_back("p"); + solution_names.emplace_back("S"); break; default: diff --git a/examples/step-22/step-22.cc b/examples/step-22/step-22.cc index 6dec38d9aa..728724642e 100644 --- a/examples/step-22/step-22.cc +++ b/examples/step-22/step-22.cc @@ -855,7 +855,7 @@ namespace Step22 StokesProblem::output_results (const unsigned int refinement_cycle) const { std::vector solution_names (dim, "velocity"); - solution_names.push_back ("pressure"); + solution_names.emplace_back("pressure"); std::vector data_component_interpretation diff --git a/examples/step-29/step-29.cc b/examples/step-29/step-29.cc index 1505344aa6..3ba142e48a 100644 --- a/examples/step-29/step-29.cc +++ b/examples/step-29/step-29.cc @@ -872,8 +872,8 @@ namespace Step29 // The solution vectors $v$ and $w$ are added to the DataOut object in the // usual way: std::vector solution_names; - solution_names.push_back ("Re_u"); - solution_names.push_back ("Im_u"); + solution_names.emplace_back("Re_u"); + solution_names.emplace_back("Im_u"); data_out.add_data_vector (solution, solution_names); diff --git a/examples/step-34/step-34.cc b/examples/step-34/step-34.cc index 566102d485..f9b1a582cb 100644 --- a/examples/step-34/step-34.cc +++ b/examples/step-34/step-34.cc @@ -880,9 +880,9 @@ namespace Step34 static std::vector > quadratures; if (quadratures.size() == 0) for (unsigned int i=0; i(singular_quadrature_order, - fe.get_unit_support_points()[i], - true)); + quadratures.emplace_back(singular_quadrature_order, + fe.get_unit_support_points()[i], + true); return quadratures[index]; } diff --git a/examples/step-35/step-35.cc b/examples/step-35/step-35.cc index 7599883b32..4fa0a55391 100644 --- a/examples/step-35/step-35.cc +++ b/examples/step-35/step-35.cc @@ -1337,8 +1337,8 @@ namespace Step35 } } std::vector joint_solution_names (dim, "v"); - joint_solution_names.push_back ("p"); - joint_solution_names.push_back ("rot_u"); + joint_solution_names.emplace_back("p"); + joint_solution_names.emplace_back("rot_u"); DataOut data_out; data_out.attach_dof_handler (joint_dof_handler); std::vector< DataComponentInterpretation::DataComponentInterpretation > diff --git a/examples/step-44/step-44.cc b/examples/step-44/step-44.cc index 6c9537354d..3ade96dcfb 100644 --- a/examples/step-44/step-44.cc +++ b/examples/step-44/step-44.cc @@ -3361,8 +3361,8 @@ namespace Step44 data_component_interpretation.push_back(DataComponentInterpretation::component_is_scalar); std::vector solution_name(dim, "displacement"); - solution_name.push_back("pressure"); - solution_name.push_back("dilatation"); + solution_name.emplace_back("pressure"); + solution_name.emplace_back("dilatation"); data_out.attach_dof_handler(dof_handler_ref); data_out.add_data_vector(solution_n, diff --git a/examples/step-46/step-46.cc b/examples/step-46/step-46.cc index b6cb342b43..e38569aea2 100644 --- a/examples/step-46/step-46.cc +++ b/examples/step-46/step-46.cc @@ -888,9 +888,9 @@ namespace Step46 output_results (const unsigned int refinement_cycle) const { std::vector solution_names (dim, "velocity"); - solution_names.push_back ("pressure"); + solution_names.emplace_back("pressure"); for (unsigned int d=0; d data_component_interpretation diff --git a/examples/step-47/step-47.cc b/examples/step-47/step-47.cc index d86bf9085c..1bf8da6d31 100644 --- a/examples/step-47/step-47.cc +++ b/examples/step-47/step-47.cc @@ -924,7 +924,7 @@ namespace Step47 Postprocessor::get_names() const { std::vector solution_names (1, "total_solution"); - solution_names.push_back ("error"); + solution_names.emplace_back("error"); return solution_names; } diff --git a/examples/step-51/step-51.cc b/examples/step-51/step-51.cc index b7fddfefe0..d9ba4cd739 100644 --- a/examples/step-51/step-51.cc +++ b/examples/step-51/step-51.cc @@ -1212,7 +1212,7 @@ namespace Step51 // We first define the names and types of the local solution, // and add the data to @p data_out. std::vector names (dim, "gradient"); - names.push_back ("solution"); + names.emplace_back("solution"); std::vector component_interpretation (dim+1, DataComponentInterpretation::component_is_part_of_vector); diff --git a/examples/step-56/step-56.cc b/examples/step-56/step-56.cc index cf243aa738..b5815f6b4c 100644 --- a/examples/step-56/step-56.cc +++ b/examples/step-56/step-56.cc @@ -1032,7 +1032,7 @@ namespace Step56 StokesProblem::output_results (const unsigned int refinement_cycle) const { std::vector solution_names (dim, "velocity"); - solution_names.push_back ("pressure"); + solution_names.emplace_back("pressure"); std::vector data_component_interpretation diff --git a/examples/step-57/step-57.cc b/examples/step-57/step-57.cc index ca3b6302db..bdf3f54f66 100644 --- a/examples/step-57/step-57.cc +++ b/examples/step-57/step-57.cc @@ -760,7 +760,7 @@ namespace Step57 void StationaryNavierStokes::output_results (const unsigned int output_index) const { std::vector solution_names (dim, "velocity"); - solution_names.push_back ("pressure"); + solution_names.emplace_back("pressure"); std::vector data_component_interpretation diff --git a/examples/step-7/step-7.cc b/examples/step-7/step-7.cc index 0e722b49c8..9e7260de04 100644 --- a/examples/step-7/step-7.cc +++ b/examples/step-7/step-7.cc @@ -1228,9 +1228,9 @@ namespace Step7 // Selecting and re-ordering the columns works as follows (note that // this includes super columns): std::vector new_order; - new_order.push_back("n cells"); - new_order.push_back("H1"); - new_order.push_back("L2"); + new_order.emplace_back("n cells"); + new_order.emplace_back("H1"); + new_order.emplace_back("L2"); convergence_table.set_column_order (new_order); // For everything that happened to the ConvergenceTable until this diff --git a/examples/step-8/step-8.cc b/examples/step-8/step-8.cc index 1df8b0d2a2..1ed56e2a46 100644 --- a/examples/step-8/step-8.cc +++ b/examples/step-8/step-8.cc @@ -553,16 +553,16 @@ namespace Step8 switch (dim) { case 1: - solution_names.push_back ("displacement"); + solution_names.emplace_back("displacement"); break; case 2: - solution_names.push_back ("x_displacement"); - solution_names.push_back ("y_displacement"); + solution_names.emplace_back("x_displacement"); + solution_names.emplace_back("y_displacement"); break; case 3: - solution_names.push_back ("x_displacement"); - solution_names.push_back ("y_displacement"); - solution_names.push_back ("z_displacement"); + solution_names.emplace_back("x_displacement"); + solution_names.emplace_back("y_displacement"); + solution_names.emplace_back("z_displacement"); break; default: Assert (false, ExcNotImplemented()); diff --git a/tests/quick_tests/nanoflann.cc b/tests/quick_tests/nanoflann.cc index 69bd2dc0a5..ba851d6639 100644 --- a/tests/quick_tests/nanoflann.cc +++ b/tests/quick_tests/nanoflann.cc @@ -29,17 +29,17 @@ int main () std::vector > points; // Add four points - points.push_back(Point<2>(0,0)); - points.push_back(Point<2>(0,1)); - points.push_back(Point<2>(1,0)); - points.push_back(Point<2>(1,1)); + points.emplace_back(0,0); + points.emplace_back(0,1); + points.emplace_back(1,0); + points.emplace_back(1,1); deallog << "Distance from unit square:" << std::endl; std::vector > test_points; - test_points.push_back(Point<2>(.5, .5)); - test_points.push_back(Point<2>(2, 0)); - test_points.push_back(Point<2>(2, 2)); + test_points.emplace_back(.5, .5); + test_points.emplace_back(2, 0); + test_points.emplace_back(2, 2); kdtree.set_points(points); -- 2.39.5