Wywołanie destruktora

0
1: T tmp;
2: T other = tmp + T();

W linijce nr 1 tworzony jest obiekt klasy T - wywoływany jest jego konstruktor.
W linijce nr 2 potrzebujemy jeszcze T() - wywoływany jest jego konstruktor.
Czy mamy PEWNOŚĆ, że po linijce 2 zostanie wywołany destruktor obiektu tymczasowego T() ? Czy standard DOKŁADNIE reguluje czas wywołania destruktora, czy może być on jednak wywołany w linijce 4, 7, 50 i nie możemy być tego pewni?

1
  1. A destructor is invoked implicitly
    ...
    (11.4) — for a constructed temporary object when its lifetime ends (12.2).

When an implementation introduces a temporary object of a class that has a non-trivial constructor (12.1,
12.8), it shall ensure that a constructor is called for the temporary object. Similarly, the destructor shall be
called for a temporary with a non-trivial destructor (12.4). Temporary objects are destroyed as the last step
in evaluating the full-expression (1.9) that (lexically) contains the point where they were created. This is true
even if that evaluation ends in throwing an exception. The value computations and side effects of destroying
a temporary object are associated only with the full-expression, not with any specific subexpression.

1 użytkowników online, w tym zalogowanych: 0, gości: 1