"Value class instance" pattern?

Dicebot public at dicebot.lv
Sun Jul 14 10:51:38 PDT 2013


Still can't find this in the spec but I see what you are getting 
at, makes sense. I think this actually is yet another case where 
CTFE-able default constructor for structs would have been a major 
win.

On Sunday, 14 July 2013 at 17:41:35 UTC, Artur Skawina wrote:
> On 07/14/13 18:59, Dicebot wrote:
>> Ugh, rly? As far as I understand spec it should work like this:
>> 
>> T x; // sets x to T.init
>> T x = void; // don't initialize x at all, leave garbage
>
> "void-initialization of aggregate fields does *not* actually 
> disable
> initialization":
>
>    struct S {
>       T x = void;
>    }
>
>    S s; // Copies S.init -> s; including s.x.


More information about the Digitalmars-d mailing list