我必须在(C++,我正在使用MS Visual Studio 2008 SP1)中为类成员函数使用显式专用化,但是我无法成功编译它。获得成员函数的模板专门化
错误C2910: '文件::运算< <':不能明确专门
class File
{
std::ofstream mOutPutFile;
public:
template<typename T>
File& operator<<(T const& data);
};
template<typename T>
File& File::operator<< (T const& data)
{
mOutPutFile << preprosesor(data);
return *this;
}
template< >
File& File::operator<< <> (std::ofstream& out)
{
mOutPutFile << out;
return *this;
}
http://stackoverflow.com/search?q=%5BC%2B%2B%5D+specialize+member+function – 2012-04-23 14:09:55
您正在使用Windows; MSVC的版本可能是相关的。如果您提供这类信息,它通常会帮助人们给出更好的答案。 – 2012-04-23 14:10:09
[函数模板专业化格式]的可能重复(http://stackoverflow.com/questions/937744/function-template-specialization-format) – 2012-04-23 14:12:36