This should work: template conditionallyInherit(bool inherit, T) { static if (inherit) alias T conditionallyInherit; else interface conditionallyInherit {} }