Open Source Your Knowledge, Become a Contributor

Declaring non-type template parameters with auto

This is another part of the strategy to use auto everywhere. With C++11 and C++14 you can use it to automatically deduce variables or even return types, plus there are also generic lambdas. Now you can also use it for deducing non-type template parameters.

For example:

template <auto value> voidf(){ }
f<10>(); // deduces int

This is useful, as you don't have to have a separate parameter for the type of non-type parameter. Like: