diff --git a/dynare++/parser/cc/atom_assignings.cc b/dynare++/parser/cc/atom_assignings.cc index 77854187bd34836e3de24a51d3c63574220ea27c..dc4b995501f4e6710a60ca052a3a96738ac4bfc7 100644 --- a/dynare++/parser/cc/atom_assignings.cc +++ b/dynare++/parser/cc/atom_assignings.cc @@ -95,7 +95,7 @@ AtomAssignings::add_assignment_to_double(string name, double val) catch (const ParserException &e) { // should never happen - throw ParserException(string("Error parsing double ")+buf.str()+": "+e.message(), 0); + throw ParserException("Error parsing double "+buf.str()+": "+e.message(), 0); } // register name of the left hand side and put to lname2expr diff --git a/dynare++/parser/cc/dynamic_atoms.cc b/dynare++/parser/cc/dynamic_atoms.cc index f76dd0c18ec3263c9c61805f27fa6205b9e650de..580ec70d00bf5ce12e4d53b2f2740f9c99674942 100644 --- a/dynare++/parser/cc/dynamic_atoms.cc +++ b/dynare++/parser/cc/dynamic_atoms.cc @@ -335,7 +335,7 @@ DynamicAtoms::lagmap(const string &name) const auto it = vars.find(name); if (vars.end() == it) throw ogu::Exception(__FILE__, __LINE__, - std::string("Couldn't find the name ") + "Couldn't find the name " + name + " in DynamicAtoms::lagmap"); return it->second; } diff --git a/dynare++/parser/cc/fine_atoms.cc b/dynare++/parser/cc/fine_atoms.cc index 0ddc44ba183f4769ecea27fd6745e947d41de5cb..8143e074e25b910b45c1530860b53d3cb303a807 100644 --- a/dynare++/parser/cc/fine_atoms.cc +++ b/dynare++/parser/cc/fine_atoms.cc @@ -38,7 +38,7 @@ AllvarOuterOrdering::AllvarOuterOrdering(const vector<string> &allvar_outer, allvar.push_back(s); else throw ogu::Exception(__FILE__, __LINE__, - string("Variable ") + s + " is not a declared symbol in AllvarOuterOrdering constructor"); + "Variable " + s + " is not a declared symbol in AllvarOuterOrdering constructor"); } // fill in endo2all and exo2all @@ -54,7 +54,7 @@ AllvarOuterOrdering::AllvarOuterOrdering(const vector<string> &allvar_outer, exo2all[it->second] = i; else throw ogu::Exception(__FILE__, __LINE__, - string("Name ") + allvar[i] + " is neither endogenous nor exogenous variable in AllvarOuterOrdering constructor"); + "Name " + allvar[i] + " is neither endogenous nor exogenous variable in AllvarOuterOrdering constructor"); } } @@ -67,11 +67,11 @@ AllvarOuterOrdering::AllvarOuterOrdering(const vector<string> &allvar_outer, iexo++; if (iendo < endo2all.size()) throw ogu::Exception(__FILE__, __LINE__, - string("Endogenous variable ") + atoms.get_endovars()[iendo] + "Endogenous variable " + atoms.get_endovars()[iendo] +" not found in outer all ordering in AllvarOuterOrdering constructor"); if (iexo < exo2all.size()) throw ogu::Exception(__FILE__, __LINE__, - string("Exogenous variable ") + atoms.get_exovars()[iexo] + "Exogenous variable " + atoms.get_exovars()[iexo] +" not found in outer all ordering in AllvarOuterOrdering constructor"); } @@ -94,7 +94,7 @@ FineAtoms::FineAtoms(const FineAtoms &fa) { if (!varnames.query(param)) throw ogu::Exception(__FILE__, __LINE__, - string("Parameter ") + param + " does not exist in FineAtoms copy cosntructor"); + "Parameter " + param + " does not exist in FineAtoms copy cosntructor"); params.push_back(param); param_outer_map.emplace(param, params.size()-1); } @@ -103,7 +103,7 @@ FineAtoms::FineAtoms(const FineAtoms &fa) { if (!varnames.query(endovar)) throw ogu::Exception(__FILE__, __LINE__, - string("Endo variable ") + endovar + " does not exist in FineAtoms copy constructor"); + "Endo variable " + endovar + " does not exist in FineAtoms copy constructor"); endovars.push_back(endovar); endo_outer_map.emplace(endovar, endovars.size()-1); } @@ -112,7 +112,7 @@ FineAtoms::FineAtoms(const FineAtoms &fa) { if (!varnames.query(exovar)) throw ogu::Exception(__FILE__, __LINE__, - string("Exo variable ") + exovar + " does not exist in FineAtoms copy cosntructor"); + "Exo variable " + exovar + " does not exist in FineAtoms copy cosntructor"); exovars.push_back(exovar); exo_outer_map.emplace(exovar, exovars.size()-1); } @@ -137,7 +137,7 @@ FineAtoms::check_variable(const string &name) const return DynamicAtoms::check_variable(name); else { - throw ParserException(string("Variable <")+str+"> not declared.", 0); + throw ParserException("Variable <"+str+"> not declared.", 0); return -1; } } @@ -419,7 +419,7 @@ FineAtoms::name2outer_allvar(const string &name) const } throw ogu::Exception(__FILE__, __LINE__, - string("Name ") + name + " is neither endo nor exo variable in FineAtoms::name2outer_allvar"); + "Name " + name + " is neither endo nor exo variable in FineAtoms::name2outer_allvar"); return -1; } @@ -427,7 +427,7 @@ void FineAtoms::register_uniq_endo(string name) { if (varnames.query(name)) - throw ogp::ParserException(string("Endogenous variable <")+name+"> is not unique.", 0); + throw ogp::ParserException("Endogenous variable <"+name+"> is not unique.", 0); varnames.insert(name); endovars.push_back(name); endo_outer_map.emplace(std::move(name), endovars.size()-1); @@ -437,7 +437,7 @@ void FineAtoms::register_uniq_exo(string name) { if (varnames.query(name)) - throw ogp::ParserException(string("Exogenous variable <")+name+"> is not unique.", 0); + throw ogp::ParserException("Exogenous variable <"+name+"> is not unique.", 0); varnames.insert(name); exovars.push_back(name); exo_outer_map.emplace(std::move(name), exovars.size()-1); @@ -447,7 +447,7 @@ void FineAtoms::register_uniq_param(string name) { if (varnames.query(name)) - throw ogp::ParserException(string("Parameter <")+name+"> is not unique.", 0); + throw ogp::ParserException("Parameter <"+name+"> is not unique.", 0); varnames.insert(name); params.push_back(name); param_outer_map.emplace(std::move(name), params.size()-1); diff --git a/dynare++/parser/cc/matrix.ll b/dynare++/parser/cc/matrix.ll index d1277f3f11c51622e74f37a7b9c55cc54316686e..ca710f25899afb72faea8cdd78d2d21ad8e95acd 100644 --- a/dynare++/parser/cc/matrix.ll +++ b/dynare++/parser/cc/matrix.ll @@ -1,7 +1,7 @@ /* -*- C++ -*- */ /* * Copyright © 2006-2011 Ondra Kamenik - * Copyright © 2019 Dynare Team + * Copyright © 2019-2022 Dynare Team * * This file is part of Dynare. * @@ -63,7 +63,8 @@ extern void matrix_error(std::string); } . { - matrix_error(std::string{"Unrecognized character "} + matrix_text); + using namespace std::string_literals; + matrix_error("Unrecognized character "s + matrix_text); } %% diff --git a/dynare++/parser/cc/static_fine_atoms.cc b/dynare++/parser/cc/static_fine_atoms.cc index 31bf67515de8f3e7300f5972d915f7543e7da1dd..4d7406c14e624e0a19079de23aed1763d5fe5f3d 100644 --- a/dynare++/parser/cc/static_fine_atoms.cc +++ b/dynare++/parser/cc/static_fine_atoms.cc @@ -82,7 +82,7 @@ int StaticFineAtoms::check_variable(const string &name) const { if (!varnames.query(name)) - throw ParserException(string("Variable <")+name+"> not declared.", 0); + throw ParserException("Variable <"+name+"> not declared.", 0); return index(name); } @@ -150,7 +150,7 @@ void StaticFineAtoms::register_uniq_endo(string name) { if (varnames.query(name)) - throw ogp::ParserException(string("Endogenous variable <")+name+"> is not unique.", 0); + throw ogp::ParserException("Endogenous variable <"+name+"> is not unique.", 0); varnames.insert(name); register_endo(std::move(name)); } @@ -159,7 +159,7 @@ void StaticFineAtoms::register_uniq_exo(string name) { if (varnames.query(name)) - throw ogp::ParserException(string("Exogenous variable <")+name+"> is not unique.", 0); + throw ogp::ParserException("Exogenous variable <"+name+"> is not unique.", 0); varnames.insert(name); register_exo(std::move(name)); } @@ -168,7 +168,7 @@ void StaticFineAtoms::register_uniq_param(string name) { if (varnames.query(name)) - throw ogp::ParserException(string("Parameter <")+name+"> is not unique.", 0); + throw ogp::ParserException("Parameter <"+name+"> is not unique.", 0); varnames.insert(name); register_param(std::move(name)); } @@ -192,8 +192,7 @@ void StaticFineAtoms::register_endo(string name) { if (!varnames.query(name)) - throw ogp::ParserException(string("Endogenous variable <") - +name+"> not found in storage.", 0); + throw ogp::ParserException("Endogenous variable <"+name+"> not found in storage.", 0); endovars.push_back(name); endo_outer_map.emplace(std::move(name), endovars.size()-1); } @@ -202,8 +201,7 @@ void StaticFineAtoms::register_exo(string name) { if (!varnames.query(name)) - throw ogp::ParserException(string("Exogenous variable <") - +name+"> not found in storage.", 0); + throw ogp::ParserException("Exogenous variable <"+name+"> not found in storage.", 0); exovars.push_back(name); exo_outer_map.emplace(std::move(name), exovars.size()-1); } @@ -212,7 +210,7 @@ void StaticFineAtoms::register_param(string name) { if (!varnames.query(name)) - throw ogp::ParserException(string("Parameter <")+name+"> not found in storage.", 0); + throw ogp::ParserException("Parameter <"+name+"> not found in storage.", 0); params.push_back(name); param_outer_map.emplace(std::move(name), params.size()-1); } diff --git a/dynare++/src/dynare3.cc b/dynare++/src/dynare3.cc index 43709d173ce22d32ced553a2a41430a41f10f9eb..746cf21ff6136eef1d3dfd110d698ba41589fb79 100644 --- a/dynare++/src/dynare3.cc +++ b/dynare++/src/dynare3.cc @@ -1,6 +1,6 @@ /* * Copyright © 2004-2011 Ondra Kamenik - * Copyright © 2019 Dynare Team + * Copyright © 2019-2022 Dynare Team * * This file is part of Dynare. * @@ -46,7 +46,7 @@ DynareNameList::selectIndices(const std::vector<std::string> &ns) const j++; if (j == getNum()) throw DynareException(__FILE__, __LINE__, - std::string("Couldn't find name for ") + n + "Couldn't find name for " + n +" in DynareNameList::selectIndices"); res.push_back(j); } @@ -62,7 +62,7 @@ Dynare::Dynare(const std::string &modname, int ord, double sstol, Journal &jr) { std::ifstream f{modname}; if (f.fail()) - throw DynareException(__FILE__, __LINE__, std::string{"Could not open model file "}+modname); + throw DynareException(__FILE__, __LINE__, "Could not open model file "+modname); std::ostringstream buffer; buffer << f.rdbuf(); diff --git a/dynare++/src/dynare_atoms.cc b/dynare++/src/dynare_atoms.cc index ea998b068b713a77e936f15dd09960df0d5cc982..567dcb28f4d0d80250948edfe559e73c8b0bb513 100644 --- a/dynare++/src/dynare_atoms.cc +++ b/dynare++/src/dynare_atoms.cc @@ -1,6 +1,6 @@ /* * Copyright © 2006 Ondra Kamenik - * Copyright © 2019 Dynare Team + * Copyright © 2019-2022 Dynare Team * * This file is part of Dynare. * @@ -36,7 +36,7 @@ void DynareStaticAtoms::register_name(string name) { if (varnames.query(name)) - throw ogp::ParserException(string("The name ")+name+" is not unique.", 0); + throw ogp::ParserException("The name "+name+" is not unique.", 0); StaticAtoms::register_name(std::move(name)); } @@ -44,7 +44,7 @@ int DynareStaticAtoms::check_variable(const string &name) const { if (!varnames.query(name)) - throw ogp::ParserException(std::string("Unknown name <")+name+">", 0); + throw ogp::ParserException("Unknown name <"+name+">", 0); auto it = vars.find(name); if (it == vars.end()) return -1; @@ -63,7 +63,7 @@ DynareDynamicAtoms::parse_variable(const string &in, std::string &out, int &ll) left++; auto right = in.find_first_of(")}", left); if (string::npos == right) - throw ogp::ParserException(string("Syntax error when parsing Dynare atom <")+in+">.", 0); + throw ogp::ParserException("Syntax error when parsing Dynare atom <"+in+">.", 0); ll = std::stoi(in.substr(left, right-left)); } else diff --git a/dynare++/src/dynare_model.cc b/dynare++/src/dynare_model.cc index f7e155cd3d666ce03993a71811a63b207e477fd6..ce9e48dcb61485cb30e0e76de5b92918f4795eaa 100644 --- a/dynare++/src/dynare_model.cc +++ b/dynare++/src/dynare_model.cc @@ -1,6 +1,6 @@ /* * Copyright © 2006-2011 Ondra Kamenik - * Copyright © 2019 Dynare Team + * Copyright © 2019-2022 Dynare Team * * This file is part of Dynare. * @@ -549,7 +549,7 @@ int DynareParser::parse_pldiscount(const string &str) { if (!atoms.is_type(str, DynareDynamicAtoms::atype::param)) - throw ogp::ParserException(std::string{"Name "} + str + " is not a parameter", 0); + throw ogp::ParserException("Name " + str + " is not a parameter", 0); int t = atoms.index(str, 0); if (t == -1) diff --git a/dynare++/src/dynare_params.cc b/dynare++/src/dynare_params.cc index d8d67bf587e366db8af8076f42d487514d3ce797..3679ecf381404ec6e513389790c44ca50726971d 100644 --- a/dynare++/src/dynare_params.cc +++ b/dynare++/src/dynare_params.cc @@ -1,6 +1,6 @@ /* * Copyright © 2004-2011 Ondra Kamenik - * Copyright © 2019 Dynare Team + * Copyright © 2019-2022 Dynare Team * * This file is part of Dynare. * @@ -37,12 +37,13 @@ DynareParams::DynareParams(int argc, char **argv) do_irfs_all(true), do_centralize(true), qz_criterium(1.0+1e-6), help(false), version(false) { - if (argc == 1 || std::string{argv[1]} == "--help") + using namespace std::string_literals; + if (argc == 1 || argv[1] == "--help"s) { help = true; return; } - if (argc == 1 || std::string{argv[1]} == "--version") + if (argc == 1 || argv[1] == "--version"s) { version = true; return; diff --git a/mex/sources/bytecode/ErrorHandling.hh b/mex/sources/bytecode/ErrorHandling.hh index c1fe2dd101935a1664db610b9e7c5234aec7d696..c6ffd8194aa039e8ac80d44cf2a96a0d847772f5 100644 --- a/mex/sources/bytecode/ErrorHandling.hh +++ b/mex/sources/bytecode/ErrorHandling.hh @@ -206,12 +206,12 @@ public: { auto M_field = mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, symbol_type)); if (!mxIsCell(M_field)) - mexErrMsgTxt((string{"M_."} + symbol_type + " is not a cell array").c_str()); + mexErrMsgTxt(("M_."s + symbol_type + " is not a cell array").c_str()); for (size_t i = 0; i < mxGetNumberOfElements(M_field); i++) { const mxArray *cell_mx = mxGetCell(M_field, i); if (!(cell_mx && mxIsChar(cell_mx))) - mexErrMsgTxt((string{"M_."} + symbol_type + " contains a cell which is not a character array").c_str()); + mexErrMsgTxt(("M_."s + symbol_type + " contains a cell which is not a character array").c_str()); r.emplace_back(mxArrayToString(cell_mx)); } } diff --git a/mex/sources/bytecode/bytecode.cc b/mex/sources/bytecode/bytecode.cc index 710bba689c02688af16b4cb71bff446ebce911d6..0119f0ae77c95aa7bb824670c864aeb77fdcfb32 100644 --- a/mex/sources/bytecode/bytecode.cc +++ b/mex/sources/bytecode/bytecode.cc @@ -375,7 +375,7 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) double *specific_shock_int_date_ = mxGetPr(mxGetCell(shock_int_date_, i)); int nb_local_periods = mxGetM(Array_shock_paths_) * mxGetN(Array_shock_paths_); if (nb_periods < nb_local_periods) - mexErrMsgTxt((string{"The total number of simulation periods ("} + to_string(nb_periods) + mexErrMsgTxt(("The total number of simulation periods (" + to_string(nb_periods) + ") is lesser than the number of periods in the shock definitions (" + to_string(nb_local_periods)).c_str()); sextended_path[i].per_value.resize(nb_local_periods); @@ -422,7 +422,7 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) if (variable_type == SymbolType::exogenous || variable_type == SymbolType::exogenousDet) splan[i].var_num = exo_num; else - mexErrMsgTxt(("The variable '" + string{name} + "' defined as var in plan is not an exogenous or a deterministic exogenous\n").c_str()); + mexErrMsgTxt(("The variable '"s + name + "' defined as var in plan is not an exogenous or a deterministic exogenous\n").c_str()); } tmp = mxGetField(plan_struct, i, "var"); if (tmp) @@ -435,7 +435,7 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) if (variable_type == SymbolType::endogenous) splan[i].exo_num = exo_num; else - mexErrMsgTxt(("The variable '" + string{name} + "' defined as exo in plan is not an endogenous variable\n").c_str()); + mexErrMsgTxt(("The variable '"s + name + "' defined as exo in plan is not an endogenous variable\n").c_str()); } tmp = mxGetField(plan_struct, i, "per_value"); if (tmp) @@ -484,7 +484,7 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) if (variable_type == SymbolType::exogenous || variable_type == SymbolType::exogenousDet) splan[i].var_num = exo_num; else - mexErrMsgTxt(("The variable '" + string{name} + "' defined as var in pfplan is not an exogenous or a deterministic exogenous\n").c_str()); + mexErrMsgTxt(("The variable '"s + name + "' defined as var in pfplan is not an exogenous or a deterministic exogenous\n").c_str()); } tmp = mxGetField(pfplan_struct, i, "exo"); if (tmp) @@ -497,7 +497,7 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) if (variable_type == SymbolType::endogenous) spfplan[i].exo_num = exo_num; else - mexErrMsgTxt(("The variable '" + string{name} + "' defined as exo in pfplan is not an endogenous variable\n").c_str()); + mexErrMsgTxt(("The variable '"s + name + "' defined as exo in pfplan is not an endogenous variable\n").c_str()); } tmp = mxGetField(pfplan_struct, i, "per_value"); if (tmp) diff --git a/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc b/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc index 05776939e9e654e582daa9521be0f1acb1ebb0f3..f85f1616e025b08b6c049a125c37c058c1f4b17f 100644 --- a/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc +++ b/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc @@ -140,7 +140,7 @@ DynamicModelMatlabCaller::eval(int it, double *resid) mxArray *exception = mexCallMATLABWithTrap(1, plhs, 6, prhs, funcname.c_str()); if (exception) { - error_msg = std::string{"An error occurred when calling "} + funcname; + error_msg = "An error occurred when calling " + funcname; return; // Avoid manipulating null pointers in plhs, see #1832 } @@ -156,7 +156,7 @@ DynamicModelMatlabCaller::eval(int it, double *resid) mxArray *exception = mexCallMATLABWithTrap(1, plhs, 7, prhs, funcname.c_str()); if (exception) { - error_msg = std::string{"An error occurred when calling "} + funcname; + error_msg = "An error occurred when calling " + funcname; return; // Avoid manipulating null pointers in plhs, see #1832 } @@ -182,7 +182,7 @@ DynamicModelMatlabCaller::eval(int it, double *resid) mxArray *exception = mexCallMATLABWithTrap(1, plhs, 7, prhs, funcname.c_str()); if (exception) { - error_msg = std::string{"An error occurred when calling "} + funcname; + error_msg = "An error occurred when calling " + funcname; return; // Avoid manipulating null pointers in plhs, see #1832 } diff --git a/mex/sources/perfect_foresight_problem/perfect_foresight_problem.cc b/mex/sources/perfect_foresight_problem/perfect_foresight_problem.cc index 23c196714c8f334946507f0c6a0738430a10c90d..a9bb4bcf299c0d52da56dccca3a7a396c1e2f2f6 100644 --- a/mex/sources/perfect_foresight_problem/perfect_foresight_problem.cc +++ b/mex/sources/perfect_foresight_problem/perfect_foresight_problem.cc @@ -104,7 +104,7 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) // Call <model>.dynamic_g1_nz mxArray *g1_nz_plhs[3]; if (mexCallMATLAB(3, g1_nz_plhs, 0, nullptr, (basename + ".dynamic_g1_nz").c_str()) != 0) - mexErrMsgTxt((std::string{"Could not call "} + basename + ".dynamic_g1_nz").c_str()); + mexErrMsgTxt(("Could not call " + basename + ".dynamic_g1_nz").c_str()); const mxArray *nzij_pred_mx = g1_nz_plhs[0]; const mxArray *nzij_current_mx = g1_nz_plhs[1]; const mxArray *nzij_fwrd_mx = g1_nz_plhs[2]; diff --git a/preprocessor b/preprocessor index 83693e4427fd003bc05cfd14a76534c2b3043da0..13dc0a11447107e0e8d5299fa3a8bfaf89295a74 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 83693e4427fd003bc05cfd14a76534c2b3043da0 +Subproject commit 13dc0a11447107e0e8d5299fa3a8bfaf89295a74