2
http://www.boost.org/doc/libs/1_59_0/doc/html/boost_asio/reference/async_write/overload1.html 它規定緩衝區「調用者保留底層內存塊的所有權,必須保證它們在調用處理程序之前保持有效。」如何將boost :: asio :: write的緩衝區存儲爲shared_ptr?
request_buff_ = std::make_shared<boost::asio::const_buffer> (boost::asio::buffer(request_str));
其中request_str是的std :: string:
爲了做到這一點,我首先通過創建一個shared_ptr緩衝區。寫入之前然後解除引用:
boost::asio::write(socket, *request_buff_);
獲取以下編譯錯誤:
'const_iterator': is not a member of 'boost::asio::const_buffer'