I have the following code that compiles and works well:
template
T GetGlobal(const char *name);
template<>
int GetGlobal(cons
The following are alternative techniques to using boost:
Declare a typedef to a dependent name
This works because name lookup for DONT only occurs when 'T' has been replaced. This is a similar (but legal) version of the example given by Kirill
template
T GetGlobal (const char * name) {
typedef typename T::DONT CALL_THIS_FUNCTION;
}
Use an incomplete return type
This technique doesn't work for specializations, but it will work for overloads. The idea is that its legal to declare a function which returns an incomplete type, but not to call it:
template
class DONT_CALL_THIS_FUNCTION GetGlobal (const char * name);