On 3/23/12, Ed McCardell <edmcc...@hotmail.com> wrote: > Is there a way to write a template constraint that matches any > specialization of a given type?
Nope. But there are simple workarounds: class Foo(bool feature1, bool feature2) { enum _isFoo = true; } template isFoo(T) { enum bool isFoo = __traits(hasMember, T, "_isFoo"); } void useFoo(T)(T foo) if (isFoo!T) { // call methods of foo that don't change based on feature1/feature2 } void main() { Foo!(true, false) foo; useFoo(foo); }