Template matching and is expression
Simen kjaeraas
simen.kjaras at gmail.com
Thu Dec 30 15:48:44 PST 2010
Piotr Szturmaj <bncrbme at jadamspam.pl> wrote:
> static assert(isNullable!(Nullable!int));
>
> Question is, what I'm doing wrong?
The problem here is that Nullable!T is not a real type. Hence,
Nullable!int is actually
Algebraic!(int,void*). Checking for that apparently does not work as
simply as one might
hope. So, instead you should create a wrapper. This works:
struct Nullable(T) {
Algebraic!(T, void*) Nullable;
alias Nullable this;
}
template isNullable(T) {
static if (is(T X == Nullable!(U), U))
enum isNullable = true;
else
enum isNullable = false;
}
static assert(isNullable!(Nullable!int));
--
Simen
More information about the Digitalmars-d-learn
mailing list