Why doesn't std::noskipws work, or what is it supposed to do?

会有一股神秘感。 提交于 2019-11-29 13:27:47

std::noskipws tells the istream to not skip any leading white space when attempting to read a type. When there is no leading white space, then the flag has no impact.

std::skipws works as follows: std::istream always keeps a current read position. If std::skipws is set, before operator>> is called the current read position is advanced to the first non-space character.

The behavior you're seeing (stop at the first space after 'i') is caused by operator>> for std::string (and std::wstring). That operator doesn't take the std::istream flags into account. An operator<< for another type may decide otherwise and continue even across spaces.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!