Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::ws

 

std::ws is an STL stream modifier to discard whitespace up until the following character.

 

#include <cassert>
#include <sstream>
#include <string>

int main()
{
  const std::string s = "X \t \n      Y";
  std::istringstream i(s);

  std::string sub1;
  std::string sub2;

  i >> sub1 >> std::ws >> sub2;

  assert(sub1 == "X");
  assert(sub2 == "Y");
}

 

 

 

 

 

External links

 

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict