-2

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!

Emil Laine
  • 41,598
  • 9
  • 101
  • 157
Adam Hunyadi
  • 1,890
  • 16
  • 32

1 Answers1

0

I figured out what the problem was, sorry for the question's ambiguity. The implementation of Histoparams I knew was an old one. Since the header I included was guarded, I didn't even notice it was overridden. And the new one defined cuts as std::vector. Switching to that solved the problem.

Adam Hunyadi
  • 1,890
  • 16
  • 32