meh, couldn't resist: import std.stdio, std.conv, std.traits, std.complex; template isComplex(T) { static if (is(T == Complex!double)) { enum bool isComplex = true; } else static if (is(T == Complex!float)) { enum bool isComplex = true; } else static if (is(T == Complex!real)) { enum bool isComplex = true; } else { enum bool isComplex = false; } }
template isComplexOrNumeric(T) { enum bool isComplexOrNumeric = (isComplex!T || isNumeric!T); } class Example(T) if (isComplexOrNumeric!T) { T k = to!T(1); }