hacky way to get explicit default constructor on struct :P

Steven Schveighoffer schveiguy at yahoo.com
Tue Oct 31 15:21:07 UTC 2017


On 10/31/17 9:49 AM, Dmitry Olshansky wrote:
> 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 allow CTFE-able default construction.
> 

Isn't that what we already have?

-Steve


More information about the Digitalmars-d mailing list