Template matching and is expression
Piotr Szturmaj
bncrbme at jadamspam.pl
Thu Dec 30 09:08:31 PST 2010
Hello,
I'm using D2.051 and following code:
import std.variant;
template Nullable(T)
{
alias Algebraic!(T, void*) Nullable;
}
template isNullable(T)
{
static if (is(T X == Nullable!U, U))
enum isNullable = true;
else
enum isNullable = false;
}
static assert(isNullable!(Nullable!int));
and above static assert fails. Neither this works:
template isNullable(T : Nullable!U, U)
{
enum isNullable = true;
}
template isNullable(T)
{
enum isNullable = false;
}
static assert(isNullable!(Nullable!int));
Question is, what I'm doing wrong?
More information about the Digitalmars-d-learn
mailing list