-3
考虑以下功能:了解流:该功能如何工作?
template <class T>
void to_string(const T& val, string& s) {
ostringstream o;
o << val;
s = o.str();
}
我不知道这个功能是如何工作的。我有两个假设,请告诉我哪一个是正确的(如果有的话):
ostringstream
有operator<<
的重载需要什么T
是(不太可能)。有一个全局函数,签名
ostream& operator<<(ostream& stream, Sometype& t)
。这允许T
写入ostringstream
,假设它是Sometype
。
哪一个更可能是正确的?我假设第二个,但我不确定。
阅读文档并找出 – 2014-10-11 11:35:03