Reputation: 9269
While compiling my code I am getting the following error. Why is throwing an error if there is only one candidate?. Why can't it can use it?
error: no matching function for call to '
TemplateParameters::reset_template_params( const char [8], const char [11], std::vector<const Channel*>, bool, std::map<int, String, std::less<int>, std::allocator<std::pair<const int, String> > >& )
'
note: candidates are:
void TemplateParameters::reset_template_params( String, String, std::vector<const Channel*>&, bool, std::map<int, String, std::less<int>, std::allocator<std::pair<const int, String> > >& )
Upvotes: 2
Views: 11515
Reputation: 545943
There are two differences between the call and the candidate:
The first two String
arguments. If no implicit conversion from a C-string literal to this class exists, the call isn’t possible.
The vector
vs. vector&
parameter. I’m going out on a limb and assume that you are passing a temporary to a newly created vector to the function. The compiler doesn’t allow this since you cannot bind a temporary to a non-const reference. Using a const-reference instead would work here. But that of course means that the parameter cannot be modified inside the method.
Since you didn’t show how you called the code this is of course idle speculation.
Upvotes: 4
Reputation: 206596
Your function call:
TemplateParameters::reset_template_params()
passes 5 parameters and compiler cannot find a function which has the same parameters. Hence the error.
The compiler can find a function TemplateParameters::reset_template_params()
but the parameters you are passing do not match to the function declaration which compiler sees for function TemplateParameters::reset_template_params().
You need to have a overloaded version of TemplateParameters::reset_template_params()
with exactly the same parameters you are calling your function with.
Upvotes: 0
Reputation: 397
Check up your parameters, Can, every thing you have given, directly translate into the parameters, e.g: String cannot be both const char[8] or const char [11] unless specified and converted explicitly
Upvotes: 0
Reputation: 223143
You are passing in string literals, and your function expects String
s. Does your String
class have a (non-explicit
) constructor that can be called with a char const*
? If not, there's your problem.
Upvotes: 1