From 5e89921ea1e45a6ada8168fa9c8847b47dc70e0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 1 Dec 2023 14:29:23 +0100
Subject: [PATCH] Use emplace() and emplace_back() at several places

Automatically detected using clang-tidy with modernize-use-emplace check.
---
 src/DynamicModel.cc  | 10 +++++-----
 src/ParsingDriver.cc |  2 +-
 src/macro/Driver.hh  |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index a48e5502..78ae0ce3 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -1355,10 +1355,10 @@ DynamicModel::fillVarModelTableFromOrigModel() const
                        << eqn << endl;
                   exit(EXIT_FAILURE);
                 }
-              orig_diff_var_vec.push_back(diff_set.begin()->first);
+              orig_diff_var_vec.emplace_back(diff_set.begin()->first);
             }
           else
-            orig_diff_var_vec.push_back(nullopt);
+            orig_diff_var_vec.emplace_back(nullopt);
         }
 
       if (eqns.size() != lhs.size())
@@ -1702,10 +1702,10 @@ DynamicModel::fillTrendComponentModelTableFromOrigModel() const
                        << eqn << endl;
                   exit(EXIT_FAILURE);
                 }
-              orig_diff_var_vec.push_back(diff_set.begin()->first);
+              orig_diff_var_vec.emplace_back(diff_set.begin()->first);
             }
           else
-            orig_diff_var_vec.push_back(nullopt);
+            orig_diff_var_vec.emplace_back(nullopt);
         }
 
       if (eqns.size() != lhs.size())
@@ -2730,7 +2730,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel& static_model)
           else
             {
               orig_endo_nbr++;
-              neweqs_lineno.push_back(nullopt);
+              neweqs_lineno.emplace_back(nullopt);
             }
         }
     }
diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc
index 99153cea..bf40c2ea 100644
--- a/src/ParsingDriver.cc
+++ b/src/ParsingDriver.cc
@@ -3181,7 +3181,7 @@ ParsingDriver::external_function()
 void
 ParsingDriver::push_external_function_arg_vector_onto_stack()
 {
-  stack_external_function_args.push({});
+  stack_external_function_args.emplace();
 }
 
 void
diff --git a/src/macro/Driver.hh b/src/macro/Driver.hh
index e59a3b31..f68afa23 100644
--- a/src/macro/Driver.hh
+++ b/src/macro/Driver.hh
@@ -101,7 +101,7 @@ public:
   void
   pushContext()
   {
-    directive_stack.emplace(vector<DirectivePtr>());
+    directive_stack.emplace();
   }
 
   void
-- 
GitLab