Problem with non-copyable classes
Posted
by
DeadMG
on Stack Overflow
See other posts from Stack Overflow
or by DeadMG
Published on 2011-01-04T21:50:50Z
Indexed on
2011/01/04
21:54 UTC
Read the original article
Hit count: 137
c++0x
I've got some non-copyable classes. I don't invoke any of the copy operators or constructor, and this code compiles fine. But then I upgraded to Visual Studio 2010 Ultimate instead of Professional. Now the compiler is calling the copy constructor- even when the move constructor should be invoked. For example, in the following snippet:
inline D3D9Mesh CreateSphere(D3D9Render& render, float radius, float slices) {
D3D9Mesh retval(render);
/* ... */
return std::move(retval);
}
Error: Cannot create copy constructor, because the class is non-copyable. However, I quite explicitly moved it.
© Stack Overflow or respective owner