请看看这个代码并运行它:
我发现了非常奇怪的错误:
错误1个错误C2663:“分配器:: allocate_help”:2个重载没有'this'指针的合法转换没有法律转化为this指针
template<class FailureSignal>
class Allocator
{
private:
template<class Exception,class Argument>
void allocate_help(const Argument& arg,Int2Type<true>)
{
}
template<class Exception,class Argument>
std::nullptr_t allocate_help(const Argument& arg,Int2Type<false>)
{
return nullptr;
}
public:
template<class T>
void Allocate(signed long int nObjects,T** ptr = 0)const
{
allocate_help<std::bad_alloc>(1,Int2Type<true>());
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Allocator<int> all;
all.Allocate<int>(1);
return 0;
}
我完全不明白这个err味精。希望有人能帮助我。谢谢。
无法按照您的要求进行编译。 `Int2Type`没有被声明/定义 – 2010-11-30 20:02:56