我正在使用此代码编译错误。这很奇怪,因为它基本上是我另一个项目的复制粘贴。有什么线索可能导致这种情况吗?
void Connection::asyncReceiveHeader()
{
Buffer* header = new Buffer(packetHeaderSize);
ba::mutable_buffer buffer = ba::buffer(header->pointer(), header->size());
auto readHandler = bind(&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)
}
错误:
C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp: In instantiation of 'class boost::asio::detail::consuming_buffers<boost::asio::mutable_buffer, boost::asio::mutable_buffer>':
C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:209:46: required from 'class boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::mutable_buffer, boost::asio::detail::transfer_all_t, boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > > >'
C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:526:3: required from 'void boost::asio::async_read(AsyncReadStream&, const MutableBufferSequence&, ReadHandler&&) [with AsyncReadStream = boost::asio::basic_stream_socket<boost::asio::ip::tcp>; MutableBufferSequence = boost::asio::mutable_buffer; ReadHandler = boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > >&]'
..\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<Buffer, Buffers>::consuming_buffers(const Buffers&) [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<AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler>::read_op(AsyncReadStream&, const MutableBufferSequence&, CompletionCondition, ReadHandler&) [with AsyncReadStream = boost::asio::basic_stream_socket<boost::asio::ip::tcp>; MutableBufferSequence = boost::asio::mutable_buffer; CompletionCondition = boost::asio::detail::transfer_all_t; ReadHandler = boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > >]'
C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:497:61: required from 'boost::asio::detail::read_op<AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler> boost::asio::detail::make_read_op(AsyncReadStream&, const MutableBufferSequence&, CompletionCondition, ReadHandler) [with AsyncReadStream = boost::asio::basic_stream_socket<boost::asio::ip::tcp>; MutableBufferSequence = boost::asio::mutable_buffer; CompletionCondition = boost::asio::detail::transfer_all_t; ReadHandler = boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > >]'
C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:526:3: required from 'void boost::asio::async_read(AsyncReadStream&, const MutableBufferSequence&, ReadHandler&&) [with AsyncReadStream = boost::asio::basic_stream_socket<boost::asio::ip::tcp>; MutableBufferSequence = boost::asio::mutable_buffer; ReadHandler = boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > >&]'
..\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<Buffer, Buffers>::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<Buffer, Buffers>::begin_remainder_'
C:\MinGW\libraries\boost-1.52\include/boost/asio/detail/consuming_buffers.hpp: In instantiation of 'boost::asio::detail::consuming_buffers<Buffer, Buffers>::consuming_buffers(const boost::asio::detail::consuming_buffers<Buffer, Buffers>&) [with Buffer = boost::asio::mutable_buffer; Buffers = boost::asio::mutable_buffer; boost::asio::detail::consuming_buffers<Buffer, Buffers> = boost::asio::detail::consuming_buffers<boost::asio::mutable_buffer, boost::asio::mutable_buffer>]':
C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:177:67: required from 'boost::asio::detail::read_op<AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler>::read_op(boost::asio::detail::read_op<AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler>&&) [with AsyncReadStream = boost::asio::basic_stream_socket<boost::asio::ip::tcp>; MutableBufferSequence = boost::asio::mutable_buffer; CompletionCondition = boost::asio::detail::transfer_all_t; ReadHandler = boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > >; boost::asio::detail::read_op<AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler> = boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp>, boost::asio::mutable_buffer, boost::asio::detail::transfer_all_t, boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > > >]'
C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:497:61: required from 'boost::asio::detail::read_op<AsyncReadStream, MutableBufferSequence, CompletionCondition, ReadHandler> boost::asio::detail::make_read_op(AsyncReadStream&, const MutableBufferSequence&, CompletionCondition, ReadHandler) [with AsyncReadStream = boost::asio::basic_stream_socket<boost::asio::ip::tcp>; MutableBufferSequence = boost::asio::mutable_buffer; CompletionCondition = boost::asio::detail::transfer_all_t; ReadHandler = boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > >]'
C:\MinGW\libraries\boost-1.52\include/boost/asio/impl/read.hpp:526:3: required from 'void boost::asio::async_read(AsyncReadStream&, const MutableBufferSequence&, ReadHandler&&) [with AsyncReadStream = boost::asio::basic_stream_socket<boost::asio::ip::tcp>; MutableBufferSequence = boost::asio::mutable_buffer; ReadHandler = boost::_bi::bind_t<void, boost::_mfi::mf3<void, network::Connection, const boost::system::error_code&, unsigned int, network::Buffer*>, boost::_bi::list4<boost::_bi::value<network::Connection*>, boost::arg<1> (*)(), boost::arg<2> (*)(), boost::_bi::value<network::Buffer*> > >&]'
..\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<Buffer, Buffers>::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<Buffer, Buffers>::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'