I have the following code that compiles and works well:
template
T GetGlobal(const char *name);
template<>
int GetGlobal(cons
If you don't implement it, you'll at least get a linker error. If you want a compile-time error, you could do this with class templates:
template
struct GlobalGetter;
template<>
struct GlobalGetter {
static int GetGlobal(const char *name);
};
template<>
struct GlobalGetter {
static double GetGlobal(const char *name);
};
template
T GetGlobal(const char *name)
{
return GlobalGetter::GetGlobal(name);
}