3
<const char*>
は次のコードでオプションですか?私は、g ++とclangがコンパイルされていても、それはうまくいきません。機能テンプレートの特殊化タイプ - これはオプションですか?
template<typename T>
void debugRep2(T const& t) {
std::cout << "debugRep(const T& t)\n";
}
template<>
void debugRep2<const char*>(const char* const& t) {
//^^^^^^^^^^^^^
std::cout << "const char*& t\n";
}
int main() {
int n;
int *pn = &n;
debugRep2(n);
debugRep2(pn);
}
別の質問になりますが、それはこのようtempalteを特化することが可能である: 'テンプレートは、<>無効debugRep2(のconst int型&T) {} '? –
user463035818
@ tobi303私はそうは思わない、この場合はパラメータの型が矛盾する。 –
テンプレート型が義務付けられている場合は分かりますか? – mike