Answer the question
In order to leave comments, you need to log in
When is a destructor implicitly called?
Question search did not return any answers. Google and books don't give a clear answer.
The question is rather vague for me. Please list the possible options (with the exception of calls to exit the scope of the block; plus, from the same opera, on return)
Answer the question
In order to leave comments, you need to log in
Please list possible options.
Draft of the n3337 standard:
Destructors are invoked implicitly
- for constructed objects with static storage duration (3.7.1) at program termination (3.6.3),
- for constructed objects with thread storage duration (3.7.2) at thread exit,
- for constructed objects with automatic storage duration (3.7.3) when the block in which an object is created exits (6.7),
— for constructed temporary objects when the lifetime of a temporary object ends (12.2),
— for constructed objects allocated by a new- expression (5.3.4), through use of a delete-expression (5.3.5),
- in several situations due to the handling of exceptions (15.3).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question