January 15, 2016
Returning a struct with a destructor and not binding it to a variable appears to make the destructor run immediately instead of at the end of the scope.
Is this intended?

example:
http://dpaste.dzfl.pl/dd285200ba2b
January 14, 2016
On 01/14/2016 09:23 PM, rsw0x wrote:
> Returning a struct with a destructor and not binding it to a variable
> appears to make the destructor run immediately instead of at the end of
> the scope.
> Is this intended?
>
> example:
> http://dpaste.dzfl.pl/dd285200ba2b

Assuming that this rule is the same as in C++ (and I think so), the lifetime of a temporary variable is the whole expression that created it. So, the behaviour you are describing is intended.

Ali