Explicit variable template specialization with different types

Viewed 36

Consider the following code:

#include <iostream>

template <class T>
T v;

template <>
double v<char> = 123.456; // ???

int main() {
    std::cout << v<int> << " " << v<char> << "\n";
}

Why I'm allowed (gcc, clang) to specialize template variable for char type as double? What's the correct syntax for variable template specialization?

0 Answers
Related