title: Using enum as template type argument in C++
body: <p>are there any restrictions / problems using an enum as template (type) argument in C++?</p>
  
  <p>Example:</p>
  
  <pre><code>enum MyEnum
  {
      A, B, C, D, E
  };
  
  template &lt;typename _t&gt;
  class MyTemplate
  {
  public:
     _t value;
  
     void func(const _t&amp; param) { /* .... */ }
  };
  
  // ....
  
  MyTemplate&lt;MyEnum&gt; MyInstance;
  </code></pre>
  
  <hr>
  
  <p>My actual problem using MSVC++ via VS 2008 (SP1) on Win32/x86 are several compilation errors (= errors reported by the compiler) in association with classes using enums as template arguments. As my project unfortunately has become a bit complex (you can consider that as a design error :P), the template classes raising these errors are derived, nested and even specialised on a class with enum template parameter.  </p>
  
  <p>Trying to build, the compiler reports many wrong/useless errors such as "C2059: syntax error: 'public'" in lines where there is only a comment. Many of them I could fix by replacing in methods similar to the one in the example the const _t&amp; param by _t (i.e. copying the parameter), but neither could I fix all of these errors nor do I have a clue why this "helps". **I know, the simple example above compiles w/o errors.</p>
  
  <p>Using int instead of enum, my project compiles w/o errors.  </p>
  
  <p>Thanks in advance for any hint or tip!</p>
  
  <hr>
  
  <p><strong>Edit</strong>:</p>
  
  <p>After all, I seriously consider this as a compiler bug. When I tried to reproduce the errors with simplified code, I got them only in 50 % of all "builds", not very deterministic:<br>
  E.g. tried to compile, and it reported these errors. Rebuild - no change. Deleted a comment, build - no change. Rebuild - and then: no errors, compiles fine.</p>
  
  <p>I've already met a few compiler bugs (2 or 3 I guess within 20k lines of code), but this one seems to me very strange.<br>
  Any suggestions how to figure out if it <strong>is</strong> the compiler?  </p>