【发布时间】:2021-11-18 17:36:56
【问题描述】:
我有一些类似的代码:
std::istringstream iss{"SomeChars"};
// Some read ops here (though the problem stays even without them)
std::string reconst(iss.str().cbegin(), iss.str().cbegin() + iss.tellg());
std::cout << reconst << std::endl;
结果总是一些乱码。 Here 是一个演示这个的程序。
当我将iss.str() 存储在std::string_view 或std::string 中时,该程序有效。但是,我仍然有我的问题:
问题:
- 为什么程序会这样?
- 我看不出它会如何被这样解释,但这是最令人头疼的解析吗?
【问题讨论】:
标签: c++ constructor range istringstream