Using allSatisfy with template that takes multiple type arguments

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Sep 26 12:32:32 PDT 2011


import std.typetuple;
import std.traits;

alias TypeTuple!(int, float) MyTypes;
template isCompatible(T)
{
    enum bool isCompatible = allSatisfy!(isImplicitlyConvertible!T, MyTypes);
}

This won't work since the compiler tries to instantiate
isImplicitlyConvertible with a single type (it takes two types).

The reason I'm doing this is to catch bad arguments inside of a static
assert so I can give out better error messages and optionally provide
a tip (based on a version switch). The above won't work, so do you
know of a workaround?


More information about the Digitalmars-d-learn mailing list