In C++ we can easily form a template that will take a class template as its parameter. With C++14 we got variable templates. They proved to be useful in many domains but still are not first-class citizens in C++. For example, they cannot be passed as a template parameter to a template. This document proposes adding such a feature.
To check if the current type is an instantiation of a class template we can write the following type trait:
A family of such type traits can be passed to a concept:
and then be used to constrain a template:
After C++14 we learnt that variable templates are less to type (no need for a
_v helper) and are often faster to compile. The above
is_ratio type trait can be rewritten as:
However, contrary to a class template, the above variable template cannot be passed to a template at all. The syntax:
is not a valid C++ as of today.
Extend C++ template syntax with a variable template parameter kind.
Special thanks and recognition goes to Epam Systems for supporting my membership in the ISO C++ Committee and the production of this proposal.