small template and mixin frustration...
WhatMeWorry via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 6 14:52:31 PDT 2015
The solution was so trivial that I'm sorry I even posted. Here's
what worked for me:
void myDebug(alias symbol)()
{
string equalSign = " = ";
writeln(symbol.stringof ~ equalSign, symbol);
}
The calls:
myDebug!i();
myDebug!staticVerts;
myDebug!boat;
myDebug!str;
Produced:
i = 7
staticVerts = [0, 1, -1, -1, 1, -1]
boat = 3.333
str = Hey, this works
Thanks again to Ali's wonderful book. Or more specifically,
section 78.3.4 alias template parameters, p. 517.
How does .stringof, differ from __traits(identifier... ?
More information about the Digitalmars-d-learn
mailing list