テンプレート機能があります:
template<typename T>
void foo(const T& value) { bar(value); x = -1; }
一連のタイプに特化したい:
template<>
void foo<char>(const char& value) { bar(value); x = 0; }
template<>
void foo<unsigned char>(const unsigned char& value) { bar(value); x = 1; }
それは正常に動作します。これをコンパイルすると:
template<>
void foo<char*>(const char*& value) { bar(value); x = 2; }
エラーが発生します:
error C2912: explicit specialization; 'void foo(const char *&)' is not a specialization of a function template
char*
型定義せずにポインター型パラメーターで特殊化することは可能ですか?