On 15/11/2017 20:55, Ireneusz Szcześniak wrote:
I have a problem related to function template argument deduction with std::tuple (with boost::tuple too). I attach a file with the complete source you can compile. Below I describe the code.
I have a template function declaration:
template <typename T> auto get_cost(const T &); [...] But I cannot use the templated function:
get_cost(l);
I get this error:
error: use of 'auto get_cost(const T&) [with T = std::tuple<unsigned int>]' before deduction of 'auto'
The problem is that you are never actually implementing the general method, and thus the compiler can't infer what the return type should be. You are providing several "better" overloads, but this first overload still participates in overload resolution and the compiler doesn't like that it has an undetermined return type. The code compiles if you specify "void" as the return type for the above method instead (or indeed pretty much anything except "auto"), or give it an actual implementation before you try to call any of the overloads.