C++14 will allow the creation of variables that are templated. The usual example is a variable \'pi\' that can be read to get the value of the mathematical constant π for va
Another practical example for C++14's variable templates is when you need a function for passing something into std::accumulate
:
template
T const & (*maxer) (T const &, T const &) = std::max;
std::accumulate(some.begin(), some.end(), initial, maxer);
Note that using std::max
is insufficient because it can't deduce the exact signature. In this particular example you can use max_element
instead, but the point is that there is a whole class of functions that share this behavior.