On Mon, Sep 26, 2011 at 21:40, Andrej Mitrovic
<[email protected]> wrote:
> Actually now that I think about it, isOneOf!() is more to my liking.
> isImplicitlyConvertible allows too much, e.g. implicit casting of
> unsigned to signed. Even though that might be perfectly valid, I want
> to optionally allow a warning via a version switch. So I'll be using
> isOneOf.
In any case, concerning your initial question, a possibility is to
curry the template:
template isCompatible(T)
{
enum isCompatible = allSatisfy!(isIC!T, MyTypes);
}
template isIC(First)
{
template isIC(Second)
{
enum isIC = isImplicitlyConvertible!(First, Second);
}
}
So, isIC!T yields *another* template (also named isIC), that will
accept one type and be mapped on MyTypes by allSatisfy. What's cool is
that the second-level template remembers First. It's a bit like a
closure, but on types.