mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
completely implement assignOperator
This commit is contained in:
parent
165c61e7ce
commit
bf11606c1a
|
@ -5476,9 +5476,9 @@ Because we defined the destructor, we must define the copy and move operations.
|
|||
~Tracer2() { cerr << "exiting " << message << '\n'; }
|
||||
|
||||
Tracer2(const Tracer2& a) : message{a.message} {}
|
||||
Tracer2& operator=(const Tracer2& a) { message = a.message; }
|
||||
Tracer2& operator=(const Tracer2& a) { message = a.message; return *this; }
|
||||
Tracer2(Tracer2&& a) :message{a.message} {}
|
||||
Tracer2& operator=(Tracer2&& a) { message = a.message; }
|
||||
Tracer2& operator=(Tracer2&& a) { message = a.message; return *this; }
|
||||
};
|
||||
|
||||
Writing out the bodies of the copy and move operations is verbose, tedious, and error-prone. A compiler does it better.
|
||||
|
|
Loading…
Reference in New Issue
Block a user