title: Using templates for stream to avoid copying of code produces "error C4430: missing type specifier - int assumed"
body: <p>I am trying to write a template for reading/writing a structure from/to a file. </p>
  
  <p>To avoid silly mistakes I want to keep one copy of the reading/writing logic - instead of two copies in two separate read/write functions.</p>
  
  <p>but as of now I get the <code>error C4430: missing type specifier - int assumed</code>, </p>
  
  <p>I have commented where:</p>
  
  <pre><code>struct VehicleInfo
  {
      int Model;
      int WindowTint;
      int Kit;
  };
  
  template &lt;typename T&gt; stream_perform(std::ofstream&amp; stream, T&amp; what)
  {
      stream.write(reinterpret_cast&lt;char*&gt;(&amp;what), sizeof(T));
  }//error on this line
  
  template &lt;typename T&gt; stream_perform(std::ifstream&amp; stream, T&amp; what)
  {
      stream.read(reinterpret_cast&lt;char*&gt;(&amp;what), sizeof(T));
  }//error on this line
  
  template &lt;typename T&gt; T&amp; stream_op(T&amp; stream, VehicleInfo&amp; info)
  {
      stream_perform(stream, info.Model);//T int
      stream_perform(stream, info.WindowTint);//T int
      stream_perform(stream, info.Kit);//T int
      //hundreds lines more of variables
      return stream;
  }
  
  std::ofstream&amp; operator&lt;&lt;(std::ofstream&amp; stream, VehicleInfo&amp; info)
  {   
      return stream_op(stream, info);
  }
  
  std::ifstream&amp; operator&gt;&gt;(std::ifstream&amp; stream, VehicleInfo&amp; info)
  {
      return stream_op(stream, info);
  }
  </code></pre>
  
  <p>I'm wondering, the compiler can deduce all types so why can't it compile this and does it think that there is no type specified?</p>