I used a static member trick to force compilation of step 2 and still get the error message:
struct S { template <typename T> static T Sum(T t) { return t; } template <typename T, typename ... Rest> static auto Sum(T t, Rest... rest) -> decltype(t + Sum(rest...) ) { return t + Sum(rest...); } }; int main() { auto x = S::Sum(1,2,3,4,5); }
main.cpp: 17: 14: There is no corresponding function to call "Sum"
c ++ templates variadic-templates
barney
source share