 <p>You can use one of many versions of <a href="https://dlang.org/spec/expression.html#IsExpression" rel="nofollow">is expression</a>:</p> <pre><code>enum E : float { E1 = 2.0 } static if (is(typeof(E.E1) Base == enum)) { pragma(msg, Base); // float } </code></pre> <p>Implementation of your desired template could look like this:</p> <pre><code>template EnumValueType(T) if (is(T == enum)) { static if (is(T Base == enum)) alias EnumValueType = Base; } </code></pre>