A lot of classes has assignment operator (operator=) the same code as in destructor and than very similar code of copy constructor.
So is it good idea to implement the assignment in such way?
Point& operator=(const Point& point)
{
if(&point != this)
{
//Call the destructor
this->~Point();
//Make the placement new
//Assignment is made because some compilers optimise such code as just
// new Point;
Point* p_n = new (this) Point(point);
//We where placing in this place so pointers should be equal
assert(p_n == this);
}
return *this;
}