Is there something like anonymous struct?

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 4 18:33:37 PST 2013


On Mon, 04 Mar 2013 21:15:27 -0500, anonymous <anonymous at example.com>  
wrote:

> On Tuesday, 5 March 2013 at 02:01:47 UTC, eGust wrote:
>> Can I write something like this:
>>
>> __gshared immutable foo = {
>> auto
>> 	func1	= &fn1,
>> 	func2	= &fn2,
>> ...
>> }
>>
>> Or just
>>
>> ... = {
>>   &fn1, &fn2, ...
>> }
>
> import std.typecons: tuple;
> __gshared immutable foo = tuple(&fn1, &fn2, ...);

That doesn't name them.  I think you have to be more verbose when naming  
the members:

__gshared immutable foo = Tuple!(typeof(&fn1), "func1", typeof(&fn2),  
"func2")(&fn1, &fn2);

Wow, that really sucks.  Is there a better way?  I bet a mixin could help  
here...

-Steve


More information about the Digitalmars-d mailing list