title: template argument deduction with strongly-typed enumerations
body: <p>If I have a normal (weak) enumeration, I can use its enumerated values as non-type template parameters, like so:</p>
  
  <pre><code>enum { Cat, Dog, Horse };
  
  template &lt;int Val, typename T&gt; bool magic(T &amp;t)
  {
      return magical_traits&lt;Val&gt;::invoke(t);
  }
  </code></pre>
  
  <p>and call it as: <code>magic&lt;Cat&gt;(t)</code></p>
  
  <p>as far as I can see, if I have a strongly-typed enumeration and don't want to hard-code the enumeration type, I end up with:</p>
  
  <pre><code>enum class Animal { Cat, Dog, Horse };
  
  template &lt;typename EnumClass, EnumClass EnumVal, typename T&gt; bool magic(T &amp;t)
  {
      return magical_traits&lt;EnumVal&gt;::invoke(t);
  }
  </code></pre>
  
  <p>and now I have to write: <code>magic&lt;Animal, Animal::Cat&gt;(t)</code>, which seems redundant.</p>
  
  <p>Is there any way to avoid typing out both the enum class and the value, short of</p>
  
  <pre><code>#define MAGIC(E, T) (magic&lt;decltype(E), E&gt;(T));
  </code></pre>