Using IFTI to only allow params of a certain template instance?
kb3ctd2 at yahoo.com
Fri Jul 6 15:32:15 PDT 2007
Say I have a function which has a parameter whose type has to be an instance
of a particular template, like so:
OK, so the first thing I tried was something like this:
void func(T, U : Temp!(T))(U param)
but when I call it like
auto t = new Temp!(int)();
the compiler doesn't accept it, it says it can't deduce the types. It looks
right to me, though.
If I switch the order of the template parameters to func, I get different
errors (notably, an error saying that I can't have a specialization for a
Is there any way to restrict the parameter like this? I thought about using
a static assert with is(), but I can't think of how I'd check that the type
of the parameter is an instance of Temp.
More information about the Digitalmars-d-learn