title: Using streambuf when sending/getting struct
body: <p>I'm working on <code>boost::asio::streambuf</code> and found out that I can send/get a struct using it, but when I send a struct I just can't get it as I have sent it. The documentation says that one should use <code>commit()</code> and <code>consume()</code>, but where should I use them here?</p>
  
  <pre><code>struct person
  {
      int m_id;
      std::string m_message;
  };
  
  std::istream&amp; operator&gt;&gt;(std::istream&amp; in, struct person&amp; p)
  {
      return in &gt;&gt; p.m_id &gt;&gt; p.m_message;
  }
  
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, struct person&amp; p)
  {
      return out &lt;&lt; p.m_id &lt;&lt; " " &lt;&lt; p.m_message;
  }
  
  int main()
  {
      boost::asio::streambuf buf;
      std::ostream out(&amp;buf);
  
      person p;
  
      p.m_id = 1;
      p.m_message = "Hello World!";
  
      out &lt;&lt; p;
  
      std::istream in(&amp;buf);
  
      person p1;
  
      in &gt;&gt; p1;
  
      cout &lt;&lt; "ID: " &lt;&lt; p1.m_id &lt;&lt; endl;
      cout &lt;&lt; "Message: " &lt;&lt; p1.m_message &lt;&lt; endl;
  
  return 0;
  }
  </code></pre>
  
  <p>The problem is with strings so when I type only "hello" (without world), it works fine, but if I add "world!" as shown above it just doesn't see the added "world!", why?</p>