title: How do I create my own ostream/streambuf?
body: <p>For educational purposes I want to create a ostream and stream buffer to do: </p>
  
  <ol>
  <li>fix endians when doing &lt;&lt; myVar; </li>
  <li>store in a deque container instead of using std:cout or writing to a file </li>
  <li>log extra data, such as how many times I did &lt;&lt;, how many times I did .write, the amount of bytes I written and how many times I flush(). But I do not need all the info.</li>
  </ol>
  
  <p>I tried overloading but failed horribly. I tried overloading write by doing </p>
  
  <pre><code>ostream&amp; write( const char* s, streamsize n ) 
  </code></pre>
  
  <p>in my basic_stringstream2 class (I copied paste basic_stringstream into my cpp file and modified it) but the code kept using basic_ostream. I looked through code and it looks like I need to overload xsputn (which isn't mention on this page <a href="http://www.cplusplus.com/reference/iostream/ostream" rel="noreferrer">http://www.cplusplus.com/reference/iostream/ostream</a> ) but what else do I need to overload? and how do I construct my class (what does it need to inherit, etc)?</p>