I compiled and run the following code in Visual Studio 2013 and it printed that the content of the moved object didn't change. I know that moved object can only be destroyed or assigned from another object, so my code isn't standard complaint. But anyway ...
#include <iostream>
#include <vector>
#include <string>
#include <utility>
struct Foo
{
std::string str;
std::vector<int> vec;
};
int main()
{
Foo foo = {"abc", {1, 2, 3}};
Foo foo2( std::move(foo) );
std::cout << foo.str.size() << '\n' << foo.vec.size() << '\n';
return 0;
}
The output was:
3
3
Since both string and vector define move operators I expected my class would have synthesized move constructor that would leave moved object empty.
From http://msdn.microsoft.com/en-us/en-en/library/hh567368.aspx
"Rvalue references v3.0" adds new rules to automatically generate move constructors and move assignment operators under certain conditions. However, this is not implemented in Visual C++ in Visual Studio 2013, due to time and resource constraints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With