As shown in the example below, I am expecting that the compiler should add an implicit move constructor and should move the data present in obj1
into obj2
and either make the obj1
blank or have some indeterminate state.
#include <iostream>
#include <memory>
#include <mutex>
using namespace std;
class Demo
{
public:
int val = 3;
};
int main()
{
Demo obj1;
cout << "before move obj1.val :" << obj1.val << std::endl;
Demo obj2(std::move(obj1));
//Expecting obj1.val moves into obj2.val and becomes zero etc.
cout << "after move obj1.val :" << obj1.val << std::endl;
cout << "after move obj2.val :" << obj2.val << std::endl;
return 0;
}
//output:
before move obj1.val :3
after move obj1.val :3
after move obj2.val :3