[phobos] phobos commit, revision 1670

Masahiro Nakagawa repeatedly at gmail.com
Sat Jun 19 20:07:14 PDT 2010


On Sun, 20 Jun 2010 06:18:46 +0900, Philippe Sigaud  
<philippe.sigaud at gmail.com> wrote:

> Andrei:
>>> this(U)(U another) if (is(U == Tuple!(V), V...)) { ... }
>
> Sean:
>
>> Is that 'is' syntax correct?
>
>
> No, halas you can't put a V... inside an is expression. Only is(U ==
> Tuple!V, V) is authorized.
> To detect a Tuple, I use the following workaround: std.typecons.Tuple  
> has a
> .Types member, so test for it (and btw .Types will give you the V tuple):
>
> this(U)(U another) if (is(U.Types)) // U is a Tuple
>
> {
> alias U.Types V;
> ...
> }
>
> also, testing for U.stringof beginning with "Tuple!("... But I don't like
> this.
>

I use following isTuple.

template isTuple(T)
{
     enum isTuple = __traits(compiles, { void f(X...)(Tuple!X t) {};  
f(T.init); });
}


Masahiro


More information about the phobos mailing list