stringof of an TemplateAliasParameter
Simen Kjaeraas
simen.kjaras at gmail.com
Mon May 19 11:29:12 PDT 2008
On Sun, 18 May 2008 21:33:35 +0200, Matthias Walter
<Matthias.Walter at st.ovgu.de> wrote:
> Hello,
>
> suppose you have the following template:
>
> | template Foo (alias X)
> | {
> | const char[] Foo = X.stringof ~ " = null;";
> | }
>
> ... and instanciate it with a struct member ...
>
> | mixin (Foo !(mystruct.member));
>
> ... this code becomes "member = null;", although I'd like it to be
> "mystruct.member = null;" Is this intended behavior? .stringof seems to
> return only sort of a short version of the name.
>
> Of course I could make my template accept a string "mystruct.member"
> instead of an alias to make it work, but I thought this would be more
> comfortable to let the user call my mixins with variables instead of
> strings, containing variables! Or is there another way to achieve my
> needs?
>
> best regards
> Matthias Walter
You can use the meta library in Pyd.
http://www.dsource.org/projects/pyd/browser/trunk/infrastructure/meta
struct foo
{
int bar;
}
pragma(msg, qualifiednameof!(foo.bar)); // prints somemodule.foo.bar
More information about the Digitalmars-d-learn
mailing list