title: asio::streambuf to std::istream discarding new line
body: <p>I need to use the data read from an asio::socket (with ASIO_STANDALONE) as an istream</p>
  
  <p>Up to now I have this code</p>
  
  <pre><code>asio::error_code ec;
  auto bytes_transferred = asio::read_until(socket, buffer, '\n', ec);
  
  if(!ec)
  {
      buffer.commit(bytes_transferred);
      std::istream line(&amp;buffer);
      // use line
      buffer.consume(bytes_transferred);
  }
  </code></pre>
  
  <p>the problem I'm facing is that the <code>'\n'</code> appears at the end of the istream, since it is not discarded by the <code>read_until</code>.</p>
  
  <p>The declarations are</p>
  
  <pre><code>tcp::socket socket;
  asio::streambuf buffer;
  </code></pre>
  
  <p>So I need to ignore the '\n' char when constructing the stream.
  I tried (as I saw in this question <a href="https://stackoverflow.com/questions/27015803/efficient-copy-of-data-from-boostasiostreambuf-to-stdstring">efficient copy of data from boost::asio::streambuf to std::string</a> ) with</p>
  
  <pre><code>if(!ec)
  {
      // Ignore the last char ('\n')
      std::string line = std::string(asio::buffers_begin(buffer),
                                     asio::buffers_begin(buffer) + bytes_transferred - 1);
      std::stringstream ss(line);
      // use line
      buffer.consume(bytes_transferred);
  }
  </code></pre>
  
  <p>But this produces the following compile error</p>
  
  <pre><code>In instantiation of ‘struct asio::detail::buffers_iterator_types&lt;asio::basic_streambuf&lt;&gt;, char&gt;’:
  lib/asio/asio/buffers_iterator.hpp:77:46:   required from ‘class asio::buffers_iterator&lt;asio::basic_streambuf&lt;&gt;, char&gt;’
  file.h:58:78:   required from here
  lib/asio/asio/buffers_iterator.hpp:60:5: error: no type named ‘value_type’ in ‘class asio::basic_streambuf&lt;&gt;’
       {
       ^
  lib/asio/asio/buffers_iterator.hpp: In instantiation of ‘class asio::buffers_iterator&lt;asio::basic_streambuf&lt;&gt;, char&gt;’:
  file.h:58:78:   required from here
  lib/asio/asio/buffers_iterator.hpp:455:43: error: no type named ‘const_iterator’ in ‘class asio::basic_streambuf&lt;&gt;’
     typename BufferSequence::const_iterator begin_;
  </code></pre>
  
  <p>and a few others always complaining about missing types.
  I'm fairly new to C++ and this message is kind of cryptic to me, moreover I'm not sure this is the best approach, as I will have 3 copy of the same data (in the buffer, in the string and in the stream)</p>
  
  <p>What could be a possible solution to my problem?</p>