エラーがあります
C2910: 'TEMPLATE_TEST::FuncTemplateTest::InnerFunc' : cannot be explicitly specialized,
以下のコードをコンパイルしている間。テンプレート関数は2つあり、どちらも特殊です。InnerFunc
専用の外側の呼び出しを削除すると、すべてが正常に機能します。それで、問題はどこにありますか?(私はMS VS 2008を使用しています。)
class FuncTemplateTest {
public:
template<typename T>
const int OuterFunc(const T& key) const;
private:
template<typename T>
const int InnerFunc(const T& key) const;
};
template<typename T>
inline const int FuncTemplateTest::OuterFunc(const T &key) const
{
std::cout<<"Outer template\n";
return InnerFunc(key);
}
template<>
inline const int FuncTemplateTest::OuterFunc<std::string>(const std::string &key) const
{
std::cout<<"Outer special\n" << key << '\n';
InnerFunc(key); //remove this line to compile!!!
return 1;
}
template<typename T>
inline const int FuncTemplateTest::InnerFunc(const T &key) const
{
std::cout << "Inner template\nTemplate key\n";
return 0;
}
template<>
inline const int FuncTemplateTest::InnerFunc<std::string>(const std::string &key) const
{
std::cout << key << '\n';
return 1;
}