title: Is there a way to serialize automatically enums as int?
body: <p>Is there a way to serialize enums automatically as int? Every time I define a new enum and write </p>
  
  <pre><code>std::stringstream stream;
  stream &lt;&lt; myenum1;
  stream &gt;&gt; myenum2;
  </code></pre>
  
  <p>the compiler complains that the operators &lt;&lt; and >> are not defined. Do you know a way to tell the compiler to treat enums as plain int's?</p>
  
  <p>What makes the problem harder is that, actually, the serialization is inside a template. Something like this:</p>
  
  <pre><code>template &lt;typename T&gt;
  void serialize(const T&amp; value)
  {
      std::stringstream stream;
      stream &lt;&lt; value;
  }
  </code></pre>
  
  <p>So I cannot add any casts :(
  Maybe I can specialize it somehow?</p>
  
  <p>Thank you.</p>