Use operator""s to replace some calls to std::string constructor
By the way, remove other unnecessary calls to that constructor.mr#2067
parent
0107365f6a
commit
8a0eb76b1b
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
%%
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 83693e4427fd003bc05cfd14a76534c2b3043da0
|
||||
Subproject commit 13dc0a11447107e0e8d5299fa3a8bfaf89295a74
|
Loading…
Reference in New Issue