how to pass a variable name in the template in this case?
Zhenya
zheny at list.ru
Thu Aug 2 16:31:00 PDT 2012
On Thursday, 2 August 2012 at 22:36:34 UTC, Andrej Mitrovic wrote:
> On 8/3/12, Zhenya <zheny at list.ru> wrote:
>> snip
>
> You mean how to extract the variable name?
>
> import std.stdio;
>
> template T(alias a)
> {
> enum string T = __traits(identifier, a);
> }
>
> void main(string[] argv)
> {
> char f = 'a';
> writeln(T!f); // writes 'f'
> }
Huh,thank you,I understood.I just thought that by default alias
parameter is an identifier.I was surprised then I saw that
possible to pass value of variable,which is'nt enum.Could you
explain me why it is?
More information about the Digitalmars-d-learn
mailing list