Call destructor and then constructor (resetting an object)
问题 I want to reset an object. Can I do it in the following way? anObject->~AnObject(); anObject = new(anObject) AnObject(); // edit: this is not allowed: anObject->AnObject(); This code is obviously a subset of typical life cycle of an object allocated by in placement new: AnObject* anObject = malloc(sizeof(AnObject)); anObject = new (anObject) AnObject(); // My step 2. // ... anObject->~AnObject(); // My step 1. free(anObject) // EDIT: The fact I used malloc instead of new doesn't carry any