May 30, 2012 Need is expression to match Variadic Template Class Type | ||||
|---|---|---|---|---|
| ||||
Attachments:
| 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
{
import std.stdio;
writeln("Matched a Bar(T...)");
}
void main() {
Foo!0 foo = new Foo!0();
Bar!() bar = new Bar!();
foobar(foo);
foobar(bar);
}
| |||
May 30, 2012 Re: Need is expression to match Variadic Template Class Type | ||||
|---|---|---|---|---|
| ||||
Posted in reply to d coder | On Wed, 30 May 2012 14:38:50 +0200, d coder <dlang.coder@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); > } | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply