hacky way to get explicit default constructor on struct :P

Dmitry Olshansky dmitry.olsh at gmail.com
Tue Oct 31 13:49:32 UTC 2017


On Monday, 30 October 2017 at 13:24:46 UTC, Steven Schveighoffer 
wrote:
> On 10/28/17 12:59 PM, LunaticWare wrote:
>> Event if there is no default constructor on struct we can 
>> still make one that work as well as if it were implemented, 
>> here is my example n__n
>> 
>> ------
>>
> You won't ever get the same support for this as C++. D is very 
> clear that a struct must be constructable from its init value, 
> and be valid.
>
> For instance:
>
> auto p = new Player[1];
> assert(p[0].name == "Baz");
>

I think we can alllow CTFE-able default construction.





More information about the Digitalmars-d mailing list