declarations as template parameters

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 30 13:23:33 PDT 2015


On 08/30/2015 08:43 PM, Adam D. Ruppe wrote:
> On Sunday, 30 August 2015 at 16:31:17 UTC, Daniel N wrote:
>> I guess it could be possible to solve using UDA:s instead... maybe
>> I'll try that next, just checking if I'm the only one dreaming about
>> "declarations as template parameters".
>
> What I would love would be being able to pass an anonymous struct to a
> template. Then you can reflect over it to get declarations and group
> them too.
>
> (Actually, I'd love to be able to use anonymous structs anywhere a
> typename is expected. Then you could do:
>
> struct { int a; } foo; // declare a variable named foo as type struct {
> int a; }
>
> but that might break the parser.)

It does not break the parser. There's only one existing feature that can 
start with "struct{" in a place where one might want to use this 
feature, and there disambiguation is easy.


More information about the Digitalmars-d mailing list