On 03/23/2012 04:14 AM, Andrej Mitrovic wrote:
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");
}
Thanks! I was tempted to try something hacky for the constraint, like
if (T.stringof == "Foo")
but tagging the type with an enum works better all around.
--Ed