c++ - stringstream code separating words - how does this thing work? code snippet inside -


i have code found cut string words. cant figure out how while part works. how know extract words without whitespaces buf variable? seems extraction operator (>>) used both progress bits buffer, , return true loop - cant figure out how knows cut words whitespaces.

string buf; // have buffer string stringstream ss(str); // insert string stream  vector<string> tokens; // create vector hold our words  while (ss >> buf)     tokens.push_back(buf); 

that std::operator>>, not bitwise operator, , used extract formatted data, in case std::string. returns reference stream being read.

a stringstream can used in boolean context due conversion operator void*(), allowing used terminating condition in loop.


Comments

Popular posts from this blog

Glib GIOChannel -

delphi - When I encode/decode SMS PDU (GSM 7 Bit) user data, do I need prepend the UDH first? -

python - Obscure curses error message when creating a sub window -