Default initialization of struct
Jacob Carlborg
doob at me.com
Wed Feb 13 02:38:22 PST 2013
On 2013-02-13 09:49, Daniel Kozak wrote:
> 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
How would this work. What if there's another struct in scope that has
the same member(s)?
> auto entity4 = Entity(name : "Name"); // and this would be useful
> too. Eg.: for UDAs @Entity(name : "EntityName")
> }
>
Check my proposal for anonymous structs:
http://forum.dlang.org/thread/kfbnuc$1cro$1@digitalmars.com#post-kfbnuc:241cro:241:40digitalmars.com
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list