I used static struct member trick to enforce 2nd pass compilation and still get an error:
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: No matching function for call to 'Sum'