Finding out if T is a specialization of another template
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Fri Feb 18 10:02:38 PST 2011
On Fri, 18 Feb 2011 17:16:02 +0000, Sean Eskapp wrote:
> I was given this code, to check if Y is a specialization of Bar. How
> does it work?
>
> class Bar(T)
> {
> }
>
> void foo(Y)()
> {
> static if (is(Y Z == Bar!Z))
> {
> // Here, Z is now an alias to whichever type Bar is //
> instantiated with.
> }
> else
> {
> // Z is invalid here.
> }
> }
I'm not sure what you mean by "how does it work". If it's the is()
expression you're wondering about, it's documented here:
http://www.digitalmars.com/d/2.0/expression.html#IsExpression
-Lars
More information about the Digitalmars-d-learn
mailing list