没有法律转换为'this'指针

The*_* do 7 c++ templates

请看一下这段代码然后运行它:
我得到了非常奇怪的错误:
错误1错误C2663:'Allocator :: allocate_help':2个重载没有'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;
}  
Run Code Online (Sandbox Code Playgroud)

我绝对不明白这个错误的消息.希望有人可以帮助我.谢谢.

fbr*_*eto 12

我注意到Allocate已经宣布constallocate_help不是 - 这可能与问题有关吗?

  • @There:搜索和[你会发现](http://msdn.microsoft.com/en-us/library/bhx1a546.aspx"编译器错误C2663").有两个建议的决议.*1:从对象声明中删除**const**.2.将**const**添加到其中一个成员函数重载.*(这是搜索C2663时Google上的第一个命中) (2认同)