title: Why enumeration cannot be a template?
body: <p><code>enumeration cannot be a template</code> is the error given when I try to compile with <a href="http://docwiki.embarcadero.com/RADStudio/XE3/en/BCC64.EXE,_the_C++_64-bit_Windows_Compiler" rel="nofollow">BCC64</a> (based on Clang) the following code:</p>
  
  <pre><code>template &lt;typename T&gt; enum class fooEnum : T
  {
      a,b,c,d,e
  };
  </code></pre>
  
  <p>At first, I was thinking that this explicit prohibition was due to the <code>enum</code> underlying type limitations, if the enum underlying type could be templated, then it could lead to ill-formed enums, but when we try this:</p>
  
  <pre><code>template &lt;typename A&gt; struct fooClass
  {
      enum class fooEnum : A
      {
          a,b,c,d,e
      };
  };
  </code></pre>
  
  <p>It compiles without problem as long as the <code>A</code> type follows the same limitations as the enum underlying types, you know, the expression that defines the value of an enumeration:</p>
  
  <ul>
  <li>Shall be an integer constant large enough to fit all the values of the enum</li>
  <li>Each enumerated type shall be compatible with <code>char</code> or a <code>signed</code>/<code>unsigned</code> integer type.</li>
  </ul>
  
  <p>If we do not not follow this rules, (with an in-class or a global enum) another specific error shows up, as expected:</p>
  
  <pre><code>enum class fooEnum : fooClass
  {
      a,b,c,d,e
  };
  </code></pre>
  
  <blockquote>
    <p>non-integral type 'fooClass' is an invalid underlying type</p>
  </blockquote>
  
  <p>So, that's why I'm wondering why is explicitly forbidden to create a template enum even when there is already a control over the underlying type. Where on the standard is mentioned this prohibition?</p>
  
  <p>Thanks for your attention.</p>