Let's say I have this class:
class Test
{
public:
Test();
};
AFAIK, compiler provides default copy constructor and assignment operators, which assign every member of other instance to the current instance. Now I add move constructor and assignment:
class Test
{
public:
Test();
Test(Test&& other);
Test& operator=(Test&& other);
};
Does this class still contain compiler-generated copy constructor and assignment operators, or I need to implement them?
Edit. This is my test:
class Test
{
public:
Test(){}
Test(Test&& other){}
Test& operator=(Test&& other)
{
return *this;
}
int n;
char str[STR_SIZE];
};
int main()
{
Test t1;
t1.n = 2;
strcpy(t1.str, "12345");
Test t2(t1);
Test t3;
t3 = t1;
cout << t2.n << " " << t2.str << " " << t3.n << " " << t3.str << endl;
return 0;
}
Prints 2 12345 2 12345
. Compiler: VC++ 2010. According to this test, copy constructor and assignment are still here. Is this standard behavior, can I be sure that this will work on every C++ compiler?