Problem with “moveable-only types” in VC++ 2010

末鹿安然 提交于 2019-12-01 03:19:40

Unfortunately, /Za is buggy. It performs an elided-copy-constructor-accessibility check when it shouldn't (binding rvalue references doesn't invoke copy constructors, even theoretically). As a result, /Za should not be used.

Stephan T. Lavavej, Visual C++ Libraries Developer (stl@microsoft.com)

First of all, you need a close ):

vec.push_back(int_ptr(new int(2))); // compiler error

Now I have no compiler error neither the first nor the second case.

I use Visual Studio 2010 Beta.

I noticed that I had disabled language extensions (\Za). With the extensions enabled, the code gets correctly compiled. I still think this is a bug since the code presented here is perfectly standard (as far as I know) and does not rely on any Microsoft extensions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!