c – 没有合法转换为’this’指针
发布时间:2020-12-16 04:51:30 所属栏目:百科 来源:网络整理
导读:请查看此代码并运行它: 我收到了很奇怪的错误: 错误1错误C2663:’Allocator :: allocate_help’:2个重载没有’this’指针的合法转换 templateclass FailureSignalclass Allocator{private: templateclass Exception,class Argument void allocate_help(c
请查看此代码并运行它:
我收到了很奇怪的错误: 错误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; } 我绝对不明白这个错误的消息.希望有人可以帮助我.谢谢. 解决方法
我注意到Allocate被声明为const但是allocate_help不是 – 这可能与问题有关吗?
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |