我有这个代码:
std::string s = "\n\n\n\n+\n\n\n+";
std::stringstream serializedDataStream(s);
std::string plusCharacter, plusCharacter2;
serializedDataStream >> plusCharacter ;
cout << "plusCharacter "<<plusCharacter << "\n";
serializedDataStream >> plusCharacter2 ;
cout << "plusCharacter "<<plusCharacter2;
//OUTPUT:
// plusCharacter +
// plusCharacter +
这意味着stringsteam
>>
操作员跳过了新行。我查看了std::stringstream
文档,但找不到发生这种情况的解释。这是编译器特定的行为,还是我可以依赖它?