Is there any reason to check for self assignment, if you're not using array's or pointers, when overloading the = operator?

For example, if the only datatypes in Vehicle are int cylinders and string manufacturer, do I really need to check before assigning? If so, what's the point?

> if the only datatypes in Vehicle are int cylinders and string manufacturer, do I really need to check before assigning?
you really do not need to write an assignment operator at all; the compiler will synthesize a (non-trivial) assignment operator with the correct semantics.

> If so, what's the point?
only efficiency (avoid the call to string's operator=, which would check for a self assignment in any case).

This article has been dead for over six months. Start a new discussion instead.