On Friday, 2 December 2016 at 10:16:17 UTC, Jacob Carlborg wrote:
Using an alias without a template constraint works for me.
I was attempting to support all methods. new class isn't the
cleanest way of doing things either, so I decided I'd support all
the things and let the user choose what they're comfortable with.
But I did derp a bit, and realised that I could have just changed
the string mixin method to not invoke the main template with
typeof( return value ).
Thus:
mixin template BitPack( alias Descriptor, string NameAlias =
typeof( Descriptor ).stringof )
{
mixin( GenerateBitPackBody!( typeof( Descriptor ), NameAlias
)() );
}
mixin template BitPack( string ElementDescriptor, string
NameAlias = "BitPackData" )
{
mixin( "mixin BitPack!( { struct BitPackData { " ~
ElementDescriptor ~ " } return BitPackData.init; }(), NameAlias
);" );
}
Works for both string definitions and inlined new class
definitions.