On Thu, 18 Dec 2014 15:52:06 +0000 Low Functioning via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
> On Thursday, 18 December 2014 at 15:48:02 UTC, Mathias LANG wrote: > > An exemple being fullyQualifiedName: > > https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L415 > > > > I don't get this pattern. Is it documented somewhere ? > > http://dlang.org/variadic-function-templates.html that's not a question about "what it does?", but the question about "why it did this way?" the answer is simple: `alias` arguments can't accept types. i.e. template t0(T...) if (T.length == 1) { enum t0 = T[0].stringof; } template t1(alias T) { enum t1 = T.stringof; } pragma(msg, t0!int); pragma(msg, t1!int); # dmd -c -o- test.d int test.d(11): Error: template instance t1!int does not match template declaration t1(alias T) test.d(11): while evaluating pragma(msg, t1!int) but: int a; pragma(msg, t0!a); pragma(msg, t1!a); gives: a a i.e. (T...) can accept both types and symbols, and `alias` can accept only symbols. `fullyQualifiedName` then checks if T is symbol or type: static if (is(T)) ... // T is a type, process as type else ... // T is a symbold, process as symbol
signature.asc
Description: PGP signature