C++ template parameter specify the second

Viewed 137

this is my code:

template <typename T, int index>
int echo(T t) {
    return index - 1;
}
echo<3>(1); // error: invalid template argument for 'T', type expected

I think that the compiler is fully capable to deduce T. How can I do to use echo when T is the first template parameter except below:

echo<decltype(x), 3>(x);
0 Answers
Related