I have this weird error in my code, and I don't seem to be able to figure out what is going on. There are much more knowledgeable people here than I am, so I figured I'd post this question.
This code works properly:
histogram_requests -> AddHistos("trajTree",
{
.fill = "HitEfficiency_vs_Layers",
.pfs = {},
.cuts = {},
.draw = "LPE1",
.opt = "",
.ranges = {0.0, 0.0}
});
Where AddHistos is declared like this:
void AddHistos(std::string name, HistoParams hp, bool AddCutsToTitle = true);
Where HistoParams is a struct:
typedef struct HistoParams
{
std::string fill;
std::vector<const char*> pfs;
std::vector<const char*> cuts;
std::string draw;
std::string opt;
std::vector<double> ranges;
} HistoParams;
So according to the definition the type of .cuts should be std::vector of const char*. But whenever I try doing something like this:
std::vector<const char*> added_cuts = {};
if(options.add_cuts)
{
added_cuts.push_back("EffCuts");
}
histogram_requests -> AddHistos("trajTree",
{
.fill = "HitEfficiency_vs_Layers",
.pfs = {},
.cuts = added_cuts,
.draw = "LPE1",
.opt = "",
.ranges = {0.0, 0.0}
});
Then I get the following error:
error: no matching function for call to 'Custom_smart_histos::AddHistos(const char [9], brace-enclosed initializer list)'
Can someone tell me why I get this error, or how to do this properly? Thank you very much!