I am currently trying to compile the following code. First, a header file containing a class with a method template:
Somewhere else I want to call this method as follows:
int value = context.getValue<int>("foo", 5);
There I get the following error:
error: no matching function for call to 'ConfigurationContext::getValue(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int)'
I checked for obvious errors, such as the absence of includes and the like. But everything seems right. I tried to remove the pass-by-reference template type argument as follows:
template<typename T> T getValue(const std::string& name, T default) const ...
Then it compiles without any errors and also works fine, but I would still like to pass the link here ...
Does anyone know what is going on here and how to do it?
source share