B
Bob Langelaan
I hope that this topic has not already been posted on and my search skills were just too poor to find it.
My understanding of the old Rule of 3 was that if your class required one of:
1) destructor
2) overloaded copy assignment operator
3) programmer supplied copy constructor
then you class would likely require all 3 of the above. A specific examplewould be where the class ctor(s) dynamically allocates storage which is then assigned to a pointer which is a data member of the class.
From what I understand, the new move semantics added to the C++ language with advent of C++ 11 add 2 new methods to the rule of 3 so that it now becomes the rule of 5. The 2 new methods are:
4) overloaded move assignment operator
5) programmer supplied move constructor
Does this mean that if a programmer fails to add a overloaded move assignment operator and a move ctor to an exisitng class when moving form a pre C++11 compiler to a C++ 11 compiler that their solution is broken? Won't the compiler in such a situation automatically create a move ctor and a move assignment operator which will not correctly handle the moving of the dynamicresource?
Thanks in advance,
Bob
My understanding of the old Rule of 3 was that if your class required one of:
1) destructor
2) overloaded copy assignment operator
3) programmer supplied copy constructor
then you class would likely require all 3 of the above. A specific examplewould be where the class ctor(s) dynamically allocates storage which is then assigned to a pointer which is a data member of the class.
From what I understand, the new move semantics added to the C++ language with advent of C++ 11 add 2 new methods to the rule of 3 so that it now becomes the rule of 5. The 2 new methods are:
4) overloaded move assignment operator
5) programmer supplied move constructor
Does this mean that if a programmer fails to add a overloaded move assignment operator and a move ctor to an exisitng class when moving form a pre C++11 compiler to a C++ 11 compiler that their solution is broken? Won't the compiler in such a situation automatically create a move ctor and a move assignment operator which will not correctly handle the moving of the dynamicresource?
Thanks in advance,
Bob