On Friday, 2 December 2016 at 08:33:17 UTC, Jacob Carlborg wrote:
But wWhat about an anonymous class as ag0aep6g mentioned?

Usability I see is something that is key here. Having to do a typeof yourself is one extra step away from an intuitive API.

So I tried making a definition like this:

mixin template BitPack( Descriptor instance, string NameAlias = Descriptor.stringof )
{
mixin( GenerateBitPackBody!( Descriptor, Descriptor.stringof )() );
}

...but I can't work out how to make the template evaluator treat descriptor as a templated type without explicitly defining that type as the first parameter.

Even trying:

mixin template BitPack( alias Descriptor ) if( is( typeof( Descriptor ) ) )

or:

mixin template BitPack( alias Descriptor ) if( __traits( compiles, &Descriptor ) )

wasn't getting me valid code (in the case of the latter, it claims it's not a valid template value argument; in the former, it meant I would have needed to add additional constraints to the other BitPack template).

I bet there's a trick out there that'll let me do what I want. But I won't go looking for it at least.

Reply via email to