Templates and stringof...
David Nadlinger
see at klickverbot.at
Sat Aug 4 04:23:05 PDT 2012
On Saturday, 4 August 2012 at 10:08:34 UTC, Era Scarecrow wrote:
>> ---
>> mixin template BitfieldsOn(alias target, <…>) if
>> (isIntegral!(typeof(target))) {
>> mixin({
>> string code;
>> // Generate code using "target" as identifier.
>> return code;
>> }());
>> }
>>
>> mixin BitfieldsOn!(foo, <…>);
>
> I really don't see how that is an improvement.
It's a sketch of an implementation for your template which
actually works with foo being passed only as an alias parameter.
It's not a string mixin, but I tend to avoid exposing string
mixins to user code as much as possible anyway.
I'm not sure what you mean with »[…] the only acceptable input
is a string; Since strings won't hold the type information...«
– the input to BitfieldsOn is _not_ a string, it is an alias.
The trick is that you can refer to it as »target« inside the
mixin template, so the problem of obtaining the »real name« of
something doesn't even arise.
David
More information about the Digitalmars-d
mailing list