在juanchopanza建议之后,我设法得到了这个最小的例子:
#include <memory>struct a{ int b;};int main(){ typedef std::auto_ptr<a> ArgAutoptr; ArgAutoptr floatingArg; floatingArg = ArgAutoptr( new a );}
这给了我错误:
no match for 'operator=' in 'm_floatingArg = std::auto_ptr<a>(((a*)operator new(4u)))'
QNX 6.4.1与GCC 4.3.3
编辑
我设法像这样编译它.这是否按预期工作或将生成…无论恶魔auto_ptr生成什么?
ArgAutoptr floatingArg2 = ArgAutoptr( new a );floatingArg = floatingArg2;解决方法 表达式ArgAutoptr(new a)正在创建临时auto_ptr.
auto_ptr :: operator =对其参数采用非const引用,与operator =的每个其他示例不同.非const引用不能绑定到临时引用.
总结以上是内存溢出为你收集整理的c – auto_ptr无法正常工作 – 编译错误全部内容,希望文章能够帮你解决c – auto_ptr无法正常工作 – 编译错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)