Default initialization of struct

Daniel Kozak kozzi11 at gmail.com
Wed Feb 13 00:49:40 PST 2013


Hi all,

I play with structs and UDAs today, and I found out some 
limitation:

struct Entity
{
	string name;
}

void main(string[] args)
{
   Entity entity = {name : "Name"}; // static initialization by 
name
   auto entity2 = Entity(); // default initialization
   auto entity3 = {name : "Name"}; // should be nice to have
   auto entity4 = Entity(name : "Name"); // and this would be 
useful too. Eg.: for UDAs @Entity(name : "EntityName")
}



More information about the Digitalmars-d mailing list