'Why does this c++ template need reference?
I try to print the type using specilization, but this doesn't work.
template<typename T>
struct print_type {
static constexpr char const value[] = "unknown";
};
template<>
struct print_type<void> {
static constexpr char const value[] = "void";
};
template<>
struct print_type<int> {
static constexpr char const value[] = "int";
};
int main() {
cout << print_type<void>::value << endl;
}
The compiler shows:
Undefined symbols for architecture x86_64:
"print_type<void>::value", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
