Tricks to pass from a ostringstream to a istringstream

亡梦爱人 提交于 2020-01-05 10:27:44

问题


I try to make a module of compression/decompression and then use istringstream for compression and ostringstream for decompression.

My problem is that after filling my istringstream with compression datas, I'm not able to convert this stream into an ostringstream. I try :

iss.rdbuf(oss.rdbuf());

as the in and out type match but it doesn't work.

Do you have any idea ?

Thank in advance.


回答1:


stringstream::rdbuf doesn't have an overload that takes a parameter. It does, however, inherit the base class version which does have this property:

iss.basic_ios<char>::rdbuf(oss.rdbuf());

The fact that you couldn't use it originally is because the derived class version hides it.



来源:https://stackoverflow.com/questions/19687570/tricks-to-pass-from-a-ostringstream-to-a-istringstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!