【发布时间】:2013-10-29 17:42:55
【问题描述】:
我想用这样的代码直接读入一个字符串:
std::string myString(( std::ostringstream() << myInt << " "
<< myFloat << " "
<< std::boolalpha << myBool ).str());
但是 VS2012 向我投诉 basic_ostream 没有 str() 方法。
有没有办法用匿名字符串流做到这一点?
【问题讨论】:
-
此代码按原样编译并在 Clang 上运行良好。 (Apple LLVM 5.0 版(clang-500.2.79)(基于 LLVM 3.3svn))