Reset all Members of a Aggregate Instance

Chris Wright via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 5 08:28:18 PST 2015


On Sat, 05 Dec 2015 07:48:16 -0800, Ali Çehreli wrote:

> On 12/05/2015 01:32 AM, Observer wrote:
> 
>> Won't clear(c); do the trick?  ((pp187-188 of TDPL)
> 
> clear() has been renamed as destroy() but it won't work by itself
> because the OP wants a reusable object. I think, in addition to
> destroy(), the default constructor should be run:
> 
>    https://dlang.org/phobos/object.html#.destroy
> 
> Ali

The default constructor doesn't set default field values, though, which 
is why my solution involved copying ClassInfo.init.


More information about the Digitalmars-d-learn mailing list