title: error: no type named 'const_iterator' in 'class boost::asio::mutable_buffer' when trying to read using boost::asio::async_read
body: <p>I am getting compiling errors using this code. It is strange because it is basically copy-paste from my another project. Any clues what could be causing this?</p>
  
  <pre><code>void Connection::asyncReceiveHeader()
  {
      Buffer* header = new Buffer(packetHeaderSize);
      ba::mutable_buffer buffer = ba::buffer(header-&gt;pointer(), header-&gt;size());
      auto readHandler = bind(&amp;Connection::headerReceived, this, ba::placeholders::error, ba::placeholders::bytes_transferred, header);
  
      ba::async_read(socket, buffer, readHandler); // Comment this line out and it compiles (this is the line 70)
  }
  </code></pre>
  
  <p>Errors:</p>
  
  <pre><code>C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp: In instantiation of 'class boost::asio::detail::consuming_buffers&lt;boost::asio::mutable_buffer, boost::asio::mutable_buffer&gt;':
  C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:209:46:   required from 'class boost::asio::detail::read_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;, boost::asio::mutable_buffer, boost::asio::detail::transfer_all_t, boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt; &gt;'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:526:3:   required from 'void boost::asio::async_read(AsyncReadStream&amp;, const MutableBufferSequence&amp;, ReadHandler&amp;&amp;) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;; MutableBufferSequence = boost::asio::mutable_buffer; ReadHandler = boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt;&amp;]'
  ..\src\network\Connection.cpp:70:45:   required from here
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:150:5: error: no type named 'const_iterator' in 'class boost::asio::mutable_buffer'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:247:36: error: no type named 'const_iterator' in 'class boost::asio::mutable_buffer'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp: In instantiation of 'boost::asio::detail::consuming_buffers&lt;Buffer, Buffers&gt;::consuming_buffers(const Buffers&amp;) [with Buffer = boost::asio::mutable_buffer; Buffers = boost::asio::mutable_buffer]':
  C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:158:60:   required from 'boost::asio::detail::read_op&lt;AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler&gt;::read_op(AsyncReadStream&amp;, const MutableBufferSequence&amp;, CompletionCondition, ReadHandler&amp;) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;; MutableBufferSequence = boost::asio::mutable_buffer; CompletionCondition = boost::asio::detail::transfer_all_t; ReadHandler = boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt;]'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:497:61:   required from 'boost::asio::detail::read_op&lt;AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler&gt; boost::asio::detail::make_read_op(AsyncReadStream&amp;, const MutableBufferSequence&amp;, CompletionCondition, ReadHandler) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;; MutableBufferSequence = boost::asio::mutable_buffer; CompletionCondition = boost::asio::detail::transfer_all_t; ReadHandler = boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt;]'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:526:3:   required from 'void boost::asio::async_read(AsyncReadStream&amp;, const MutableBufferSequence&amp;, ReadHandler&amp;&amp;) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;; MutableBufferSequence = boost::asio::mutable_buffer; ReadHandler = boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt;&amp;]'
  ..\src\network\Connection.cpp:70:45:   required from here
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:157:58: error: 'class boost::asio::mutable_buffer' has no member named 'end'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:157:58: error: 'class boost::asio::mutable_buffer' has no member named 'begin'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:157:58: error: using invalid field 'boost::asio::detail::consuming_buffers&lt;Buffer, Buffers&gt;::begin_remainder_'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:157:58: error: 'class boost::asio::mutable_buffer' has no member named 'begin'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:161:7: error: 'class boost::asio::mutable_buffer' has no member named 'begin'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:162:7: error: using invalid field 'boost::asio::detail::consuming_buffers&lt;Buffer, Buffers&gt;::begin_remainder_'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp: In instantiation of 'boost::asio::detail::consuming_buffers&lt;Buffer, Buffers&gt;::consuming_buffers(const boost::asio::detail::consuming_buffers&lt;Buffer, Buffers&gt;&amp;) [with Buffer = boost::asio::mutable_buffer; Buffers = boost::asio::mutable_buffer; boost::asio::detail::consuming_buffers&lt;Buffer, Buffers&gt; = boost::asio::detail::consuming_buffers&lt;boost::asio::mutable_buffer, boost::asio::mutable_buffer&gt;]':
  C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:177:67:   required from 'boost::asio::detail::read_op&lt;AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler&gt;::read_op(boost::asio::detail::read_op&lt;AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler&gt;&amp;&amp;) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;; MutableBufferSequence = boost::asio::mutable_buffer; CompletionCondition = boost::asio::detail::transfer_all_t; ReadHandler = boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt;; boost::asio::detail::read_op&lt;AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler&gt; = boost::asio::detail::read_op&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;, boost::asio::mutable_buffer, boost::asio::detail::transfer_all_t, boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt; &gt;]'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:497:61:   required from 'boost::asio::detail::read_op&lt;AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler&gt; boost::asio::detail::make_read_op(AsyncReadStream&amp;, const MutableBufferSequence&amp;, CompletionCondition, ReadHandler) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;; MutableBufferSequence = boost::asio::mutable_buffer; CompletionCondition = boost::asio::detail::transfer_all_t; ReadHandler = boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt;]'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:526:3:   required from 'void boost::asio::async_read(AsyncReadStream&amp;, const MutableBufferSequence&amp;, ReadHandler&amp;&amp;) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp&gt;; MutableBufferSequence = boost::asio::mutable_buffer; ReadHandler = boost::_bi::bind_t&lt;void, boost::_mfi::mf3&lt;void, network::Connection, const boost::system::error_code&amp;, unsigned int, network::Buffer*&gt;, boost::_bi::list4&lt;boost::_bi::value&lt;network::Connection*&gt;, boost::arg&lt;1&gt; (*)(), boost::arg&lt;2&gt; (*)(), boost::_bi::value&lt;network::Buffer*&gt; &gt; &gt;&amp;]'
  ..\src\network\Connection.cpp:70:45:   required from here
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:172:32: error: using invalid field 'boost::asio::detail::consuming_buffers&lt;Buffer, Buffers&gt;::begin_remainder_'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:172:32: error: 'class boost::asio::mutable_buffer' has no member named 'begin'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:174:38: error: no type named 'const_iterator' in 'class boost::asio::mutable_buffer'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:175:38: error: no type named 'const_iterator' in 'class boost::asio::mutable_buffer'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:176:5: error: using invalid field 'boost::asio::detail::consuming_buffers&lt;Buffer, Buffers&gt;::begin_remainder_'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:174:38: error: no type named 'const_iterator' in 'class boost::asio::mutable_buffer'
  C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp:175:38: error: no type named 'const_iterator' in 'class boost::asio::mutable_buffer'
  </code></pre>