December 02, 2016 Re: Inline aggregate types | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | 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.
|
December 05, 2016 Re: Inline aggregate types | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ethan Watson | On Friday, 2 December 2016 at 11:11:30 UTC, Ethan Watson wrote:
> On Friday, 2 December 2016 at 10:16:17 UTC, Jacob Carlborg wrote:
>> [...]
>
> 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.
>
> [...]
Do you plan on contributing this back to phobos? I also came across this exact same problem.
|
December 05, 2016 Re: Inline aggregate types | ||||
---|---|---|---|---|
| ||||
Posted in reply to Guillaume Chatelet | On Monday, 5 December 2016 at 11:57:18 UTC, Guillaume Chatelet wrote:
> Do you plan on contributing this back to phobos? I also came across this exact same problem.
It'll want to go through a few polish iterations before I even think of doing that; and it'll need support for things like toString/toHash/etc.
Another critical bit of functionality that std.bitmanip provides that I currently don't is a bit array. I also want to support statically sized bit arrays, Phobos only provides support for dynamically sized.
|
December 05, 2016 Re: Inline aggregate types | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ethan Watson | On 2016-12-05 13:32, Ethan Watson wrote: > I also want to support statically sized > bit arrays, Phobos only provides support for dynamically sized. That would be nice, I had a need for that. -- /Jacob Carlborg |
Copyright © 1999-2021 by the D Language Foundation