Say that you create a library with a class MyClass
that has proper move assignment operators and move constructors. Furthermore, this library has properly defined and implemented MyClass MyClass::operator + (const MyClass& other)
. This class is compiled with -std=c++11
in order for these operators and syntax like MyClass&&
to make sense.
If you later have a program not compiled with -std=c++11
using this library and creating instances of the class MyClass
, will you be able to take advantage of move semantics?
That, is will the following call the move constructor of MyClass
?
MyClass first, second;
// initialize first and second
MyClass moved = first + second; // hopefully uses move semantics
I know that this code could not create its own class and use syntax like MyClass&&
without having compilation errors, but hopefully it would still be able to take advantage of C++11 by using the C++11 library...
Thanks for any clarification.