digitalmars.D.learn - Structs intended to run destructor immediately if not assigned to a
- rsw0x (6/6) Jan 14 2016 Returning a struct with a destructor and not binding it to a
- =?UTF-8?Q?Ali_=c3=87ehreli?= (5/11) Jan 14 2016 Assuming that this rule is the same as in C++ (and I think so), the
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
Jan 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/dd285200ba2bAssuming 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
Jan 14 2016