ostringstream传递到istringstream的技巧

ostringstream传递到istringstream的技巧

本文介绍了从ostringstream传递到istringstream的技巧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试制作一个压缩/解压缩模块,然后使用istringstream进行压缩,并使用ostringstream进行解压缩。



我的问题是在用压缩数据填充istringstream之后,我无法将此流转换为ostringstream。我尝试:

作为输入和输出类型匹配,但不起作用。



您有任何想法吗?



预先感谢。

解决方案

stringstream :: rdbuf 没有过载,参数。但是,它确实继承了具有此属性的基类版本:

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

最初无法使用它的事实是因为派生类版本将其隐藏。 p>

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 :

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

Do you have any idea ?

Thank in advance.

解决方案

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.

这篇关于从ostringstream传递到istringstream的技巧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 12:52