it
template <class locale> static void Delete(void* ptr) { delete (locale*)ptr; }
not a specialization. This is an overload. The specialization will be as follows:
template <> static void Delete(locale* ptr) { delete (locale*)ptr; }
So actually this is equivalent to writing only
template <class T> static void Delete(void* ptr) { delete (T*)ptr; }
Actually, the behavior that you presented is related to allowing line congestion
T_delete_function = &Deleter::Delete<T>;
The second overload is more specific since it accepts void* , not T* , and the type is explicitly specified anyway. Thus, in the presence of the aforementioned overload, he selects it, and it compiles and runs fine. In the absence of this more specific overload, the compiler calls another suitable, but more general, one that calls this statement.
You can double check this, i.e. remove the line #include <locale> : the compiler will not complain about the class locale not declared.
source share