According to C++1y/C++14 N3690, does the type of a variable template specialization have to be the same as the type of the primary template?
template<int x>
char y = f(x);
template<>
double y<42> = g();
And if so, is it possible to leave the primary undefined somehow?
template<int x>
???? y = ???; // undefined
template<>
double y<42> = g();
Where is this covered in the draft?
The equivalent functionality for a class template would be:
template<int x>
struct S
{
static char y;
};
template<>
struct S<42>
{
static double y;
};
and
template<int x>
struct S; // undefined
template<>
struct S<42>
{
static double y;
};
See Question&Answers more detail:os