从std :: stringstream中提取整个std :: string

Dav*_*ave 0 c++

请考虑以下代码:

std::stringstream test;
test << std::string("This is a test.");
std::string str;
test >> str;
std::cout << "\"" << str << "\"" << std::endl;
Run Code Online (Sandbox Code Playgroud)

这只输出字符串"This",而不是"This is a test".

为什么会这样,我怎样才能获得整个字符串?