Информация об изменениях

Сообщение Re[2]: placement new (this) в конструкторе от 02.04.2018 16:49

Изменено 02.04.2018 16:53 σ

Re[2]: placement new (this) в конструкторе
Здравствуйте, MasterZiv, Вы писали:

MZ>Для каждого объекта, для которого вызван конструктор, должен быть вызван деструктор.


http://eel.is/c++draft/basic.life#5:
A program may end the lifetime of any object by reusing the storage which the object occupies or by explicitly calling the destructor for an object of a class type with a non-trivial destructor.
For an object of a class type with a non-trivial destructor, the program is not required to call the destructor explicitly before the storage which the object occupies is reused or released;
Re[2]: placement new (this) в конструкторе
Здравствуйте, MasterZiv, Вы писали:

MZ>Для каждого объекта, для которого вызван конструктор, должен быть вызван деструктор.


Такого правила нет.

Можно переиспользовать память под объектом не вызывая его деструктора http://eel.is/c++draft/basic.life#5:
A program may end the lifetime of any object by reusing the storage which the object occupies or by explicitly calling the destructor for an object of a class type with a non-trivial destructor.
For an object of a class type with a non-trivial destructor, the program is not required to call the destructor explicitly before the storage which the object occupies is reused or released;

(Это, конечно, не позволяет placement new в конструкторе).