如何将 streambuf 中的数据复制到无符号字符数组?下面的代码有编译器错误:
boost::asio::streambuf buf;
std::ostream os(&buf);
boost::archive::binary_oarchive oa(os);
oa << m_data;
// allocate space for the buffer
unsigned char* output = (unsigned char*)malloc(buf.size());
buf >> output;
编译器错误是(在最后一行):
错误 C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &&,_Elem *)' : 无法推断 'std::basic_istream<_Elem, _Traits> &&' from 'boost::asio::streambuf' 1> D:\program\Microsoft Visual Studio 10.0\VC\include\istream(987) : 见 'std::operator >>' 的声明
错误 C2676:二进制“>>”:“boost::asio::streambuf”未定义此运算符或转换为预定义运算符可接受的类型