Template alias parameter does not accept types

Dicebot m.strashun at gmail.com
Thu May 9 06:38:29 PDT 2013


On Thursday, 9 May 2013 at 13:27:35 UTC, Steven Schveighoffer 
wrote:
> template GetString(T) if (is(T == int) || is(T == float) || ...)
> {
>    enum string GetString = T.stringof;
> }

Current idiomatic D way to handle both built-in types and symbols 
looks like this:

template Hello(T...)
     if (T.length == 1)
{
     static if (is(T[0]))
         // ...
     else
         // ...
}

I actually don't understand why it accepts literals as those are 
not symbols and, for example, you can't attach UDA to literal.


More information about the Digitalmars-d-learn mailing list