Templates and stringof...

Philippe Sigaud philippe.sigaud at gmail.com
Sat Aug 4 01:07:53 PDT 2012


"Era Scarecrow" <rtcvb32 at yahoo.com>

>  Then doesn't it seem like we're missing a potentially important piece of
the puzzle for mixins and templates? very likely my modified template will
include you including the same variable twice, but if someone gets lazy
then it may not work.
>
>  mixin(bitfieldsOn!("SomeVariable", SomeVariable, /*stuff*/));
>  // or
>  mixin(bitfieldsOn!("SomeVariable", variable type, /*stuff*/));

Hmm. You can ask for just the name as a string (so, qualified or not, as
the user wish) and include a test for the type of the passed name.

inside bitfieldsOn:

    mixin("
static if is(typeof("~name~"))
        alias typeof(" ~ name ~ ") NameType;
    else
        static assert(false, `bad name given to bitfieldsOn:"~name~".`);
")

Untested, I'm on a pad right now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120804/3881a30a/attachment.html>


More information about the Digitalmars-d-learn mailing list