strstream折旧 [英] strstream depreciation

查看:76
本文介绍了strstream折旧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的应用程序使用''strstream''只有不到一半的.cc

文件,大约10个文件。


''strstream'的替代品是什么?

我可以选择更换它吗?


非常感谢提前,


Aaron

Hi,

I have an application that uses ''strstream'' in just under half its .cc
files, about 10 files.

What is the replacement for ''strstream'' ?
What are my options for replacing it ?

Many thanks in advance,

Aaron

推荐答案

文章< 42 ****** *****************@ptn-nntp-reader03.plus.net> ;,

" Aaron Gray" < AA ******** @ gmail.com>写道:
In article <42***********************@ptn-nntp-reader03.plus.net>,
"Aaron Gray" <aa********@gmail.com> wrote:


我有一个应用程序使用''strstream''只有不到一半的.cc
文件,大约10文件。

strstream的替代品是什么?
有什么替代它的选择?

非常感谢提前,

Aaron
Hi,

I have an application that uses ''strstream'' in just under half its .cc
files, about 10 files.

What is the replacement for ''strstream'' ?
What are my options for replacing it ?

Many thanks in advance,

Aaron




尝试下列之一:


ostringstream

istringstream

stringstream


这些都在标题< sstream>中。


一个机会并不是很糟糕简单的查找/替换将让你去

没有故障。主要区别在于stringstream系列

不会暴露其内部缓冲区,因此不太容易受到内存泄漏的影响。


strstream已被弃用,因为它容易出现内存泄漏。那不是说b $ b说正确使用它可能会导致内存泄漏,只是因为它很容易被误用,导致内存泄漏。 br />

话虽如此,strstream履行的角色还没有在std :: lib中取代
:指定缓冲区的能力

读/写交互。如果你需要指定缓冲区(比如

性能原因或其他原因),stringstream系列将不会为你做b / b
。这个应用程序在std :: lib中没有替代方案。


虽然strstream已经被弃用了将近十年,但我并没有预料到b $ b将它从C ++ 0X中删除,因为上面提到的功能没有覆盖

。我毫不怀疑可以为这个功能设计一个更好的设施

,但迄今为止还没有人提出任何建议。


-Howard



Try one of:

ostringstream
istringstream
stringstream

which are all in the header <sstream>.

The chances aren''t bad that a simple find/replace will get you going
without a hitch. The main difference is that the stringstream family
doesn''t expose its internal buffer and is thus less susceptible to
memory leaks.

strstream is deprecated because it is memory leak prone. That is not to
say that correct usage of it might result in a memory leak, just that it
is so easy to misuse it, resulting in a memory leak.

That being said, strstream fulfills a role that has not yet been
replaced in the std::lib: The ability to specify the buffer which the
read/write interacts with. If you need to specify the buffer (say for
performance reasons or whatever), the stringstream family will not do it
for you. There is no alternative in the std::lib for this application.

Although strstream has been deprecated for nearly a decade, I don''t
anticipate removing it from C++0X because of the lack of covering the
above mentioned functionality. I have no doubt that a better facility
could be designed for this functionality, but no one to date has
proposed anything.

-Howard


>尝试下列之一:
> Try one of:

ostringstream
istringstream
stringstream

这些都在标题< sstream>中。

话虽这么说,strstream完成了一个尚未在std :: lib中替换的角色:指定读/写与之交互的缓冲区的能力。如果你需要指定缓冲区(比如
性能原​​因或其他原因),stringstream系列将不会为你做这个。此应用程序的std :: lib中没有其他选择。


这是它的主要用法。

虽然strstream已被弃用近十年,但我并不期待将其从C ++ 0X因为缺乏覆盖上述功能。我毫不怀疑可以为这个功能设计一个更好的设施,但迄今为止还没有人提出任何建议。

ostringstream
istringstream
stringstream

which are all in the header <sstream>.

That being said, strstream fulfills a role that has not yet been
replaced in the std::lib: The ability to specify the buffer which the
read/write interacts with. If you need to specify the buffer (say for
performance reasons or whatever), the stringstream family will not do it
for you. There is no alternative in the std::lib for this application.
Right this is its main usage.
Although strstream has been deprecated for nearly a decade, I don''t
anticipate removing it from C++0X because of the lack of covering the
above mentioned functionality. I have no doubt that a better facility
could be designed for this functionality, but no one to date has
proposed anything.




也许我然后会为这个应用程序提供一些替换代码。

以太或者保持strstream并喜欢它并将它混为一谈。


我可以忽略它现在使用''-Wno-deprecated''开关。


感谢您的解释。


Aaron



Maybe I will come up with some replacement code for ths app then.
Ether that or keep strstream and like it and lump it.

I can just ignore it for now and use a ''-Wno-deprecated'' switch.

Thanks for your explanation.

Aaron


Aaron Gray写道:
Aaron Gray wrote:
尝试下列之一:

ostringstream
istringstream
stringstream

这些都在标题< sstream>中。

即便如此,strstream履行了一个尚未在std中替换的角色:: lib:指定读/写与之交互的缓冲区的能力。如果你需要指定缓冲区(比如
性能原​​因或其他原因),stringstream系列将不会为你做这个。这个应用程序在std :: lib中没有替代方法。
Try one of:

ostringstream
istringstream
stringstream

which are all in the header <sstream>.

That being said, strstream fulfills a role that has not yet been
replaced in the std::lib: The ability to specify the buffer which the
read/write interacts with. If you need to specify the buffer (say for
performance reasons or whatever), the stringstream family will not do it
for you. There is no alternative in the std::lib for this application.



这是它的主要用途。



Right this is its main usage.

虽然strstream已被弃用近十年来,由于缺乏上述功能,我不希望将其从C ++ 0X中删除。我毫不怀疑可以为这个功能设计一个更好的设施,但是到目前为止还没有人提出任何建议。
Although strstream has been deprecated for nearly a decade, I don''t
anticipate removing it from C++0X because of the lack of covering the
above mentioned functionality. I have no doubt that a better facility
could be designed for this functionality, but no one to date has
proposed anything.



也许我会想出来那个应用程序的一些替换代码然后。
以太或者保持strstream并喜欢它并把它搞砸了。

我现在可以忽略它并使用''-Wno-deprecated''开关。

感谢您的解释。

Aaron



Maybe I will come up with some replacement code for ths app then.
Ether that or keep strstream and like it and lump it.

I can just ignore it for now and use a ''-Wno-deprecated'' switch.

Thanks for your explanation.

Aaron




stringstream允许您指定缓冲区,例如


std :: string str;

char * pCh;


//放东西进入''str''...

// make''pCh''指向一些char数组...


//制作一个字符串流来自''str''的副本

std :: stringstream s1(str);

//从''* pCh''的COPY中创建一个字符串流br />
std :: stringstream s2(pCh);

//从你好那里的COPY中创建一个字符串流

std :: stringstream s3(你好那里);


s1,s2和s3使用COPY

数据创建一个std :: stringstream由他们的构造函数arg指定。


无法创建一个字符串流来访问固定的

地址作为其字符串缓冲区(例如一些特定的内存

地址)因为stringstream总是复制

任何字符串arg传递给它的构造函数。



stringstream does allow you to specify a buffer, e.g.

std::string str;
char * pCh;

// put stuff into ''str''...
// make ''pCh'' point to some char array...

// make a stringstream from a COPY of ''str''
std::stringstream s1(str);
// make a stringstream from a COPY of ''*pCh''
std::stringstream s2(pCh);
// make a stringstream from a COPY of "hello there"
std::stringstream s3("hello there");

s1, s2, and s3 make a std::stringstream using a COPY
of the data specified by their constructor arg.

One can not create a stringstream that access a fixed
address as its string buffer (e.g. some specific memory
address) because stringstream always makes a COPY of
any string arg passed to its constructor.


这篇关于strstream折旧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆