Need is expression to match Variadic Template Class Type

Simen Kjaeraas simen.kjaras at gmail.com
Wed May 30 05:46:12 PDT 2012


On Wed, 30 May 2012 14:38:50 +0200, d coder <dlang.coder at gmail.com> wrote:

> Greetings
>
> What would be the form of "is" expression to match with a Variadic  
> Template
> Class?
> I am pasting a simple example below to clarify my need. I need an is
> expression to match with the Bar(T...) type in the code below.
>
> Regards
> - Puneet
>
> class Foo(int N=0) {}
>
> class Bar(T...) {}
>
> void foobar(L) (ref L l)
>   if(is(L f : Foo!N, int N))
>     {
>       import std.stdio;
>       writeln("Matched a Foo(int N)");
>     }
>
> void foobar(L) (ref L l)
>   if // WHAT IS EXPRESSION SHOULD COME HERE

is(L unused : Bar!T, T...)



>     {
>       import std.stdio;
>       writeln("Matched a Bar(T...)");
>     }
>
> void main() {
>   Foo!0 foo = new Foo!0();
>   Bar!() bar = new Bar!();
>   foobar(foo);
>   foobar(bar);
> }


More information about the Digitalmars-d mailing list