|
|
|
|
@ -11762,9 +11762,8 @@ If you define a destructor, you should not use the compiler-generated copy or mo
|
|
|
|
|
// ...
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
~X() { /* custom stuff, such as closing hnd */ }
|
|
|
|
|
|
|
|
|
|
// suspicious: no mention of copying or moving -- what happens to hnd?
|
|
|
|
|
~X() { /* custom stuff, such as closing hnd */ }
|
|
|
|
|
// suspicious: no mention of copying or moving -- what happens to hnd?
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
X x1;
|
|
|
|
|
@ -11777,18 +11776,18 @@ If you define copying, and any base or member has a type that defines a move ope
|
|
|
|
|
string s; // defines more efficient move operations
|
|
|
|
|
// ... other data members ...
|
|
|
|
|
public:
|
|
|
|
|
x(const x&) { /* stuff */ }
|
|
|
|
|
x& operator=(const x&) { /* stuff */ }
|
|
|
|
|
x(const x&) { /* stuff */ }
|
|
|
|
|
x& operator=(const x&) { /* stuff */ }
|
|
|
|
|
|
|
|
|
|
// BAD: failed to also define a move construction and move assignment
|
|
|
|
|
// (why wasn't the custom "stuff" repeated here?)
|
|
|
|
|
};
|
|
|
|
|
// BAD: failed to also define a move construction and move assignment
|
|
|
|
|
// (why wasn't the custom "stuff" repeated here?)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
x test()
|
|
|
|
|
{
|
|
|
|
|
x local;
|
|
|
|
|
// ...
|
|
|
|
|
return local; // pitfall: will be inefficient and/or do the wrong thing
|
|
|
|
|
// ...
|
|
|
|
|
return local; // pitfall: will be inefficient and/or do the wrong thing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
If you define any of the copy constructor, copy assignment operator, or destructor, you probably should define the others.
|
|
|
|
|
|