[cpp] RE: Cpp Digest, Vol 32, Issue 5
Lingoes
lingoes at gmail.com
Thu Nov 23 02:56:01 CST 2006
我知道这不是好的习惯, 使用这个技巧, 主要是出于现实应用的考虑, 确实对性能有很大提升, 所以想看看大家有什么更好的方法.
2006/11/14, ji li <leesoft76 at hotmail.com>:
>
> 对string的写操作和已通过 ostringstream 转接,很方便。
> #define MAKE_STRING(msg) (((ostringstream&)(ostringstream() <<
> msg)).str())
> string strTest;
> strTest = MAKE_STRING("String Msg : " << strParam << ", integer= " <<
> nParam);
>
> 如果真得很在意性能的话,应该尽量减少字符串操作,无论是string还是char*,所有的字符串操作都是低效的。
> 直接访问string缓冲区破坏了string的封装机制,不是好习惯。
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20061123/af7556fb/attachment.html
More information about the Cpp
mailing list