Copy a streambuf's contents to a string

前端 未结 10 2016
时光取名叫无心
时光取名叫无心 2020-11-29 22:19

Apparently boost::asio::async_read doesn\'t like strings, as the only overload of boost::asio::buffer allows me to create const_buffer

10条回答
  •  旧时难觅i
    2020-11-29 23:14

    I think it's more like:

    
    streambuf.commit( number_of_bytes_read );
    
    istream istr( &streambuf );
    string s;
    istr >> s;
    

    I haven't looked into the basic_streambuf code, but I believe that should be just one copy into the string.

提交回复
热议问题