I’m running these two lines of code to add to a map later on:
o.add("-i", 800, "int option");
o.add("-w", "'switch on' option (no third parameter)");
To add them i’m using my two add functions defined as:
template<class T>
void add(std::string name, T value, std::string desc);
template<class T>
void add(std::string name, std::string desc);
The first one works fine, and returns the values I want, but if I add the second one, I get the error:
error: no matching function for call to ‘Opt::add(const char [3], const char [40])’
My question is why it’s using my strings in the first one properly, and my strings in the second are being thought of as const char arrays.
Thank you in advance.
Since you’re not using the template argument in your second overload, remove it:
A working sample can be found here.