| for istream | istream& ws (istream& is); |
|---|---|
| basic template | template <class charT, class traits>basic_istream<charT,traits>& ws (basic_istream<charT,traits>& is); |
true). Then (if good ), it extracts characters from is's associated stream buffer object as if calling its member functions sbumpc or sgetc , and finally destroys the sentry object before returning.>>) operations on input streams (see example below).| flag | error |
|---|---|
| eofbit | The function stopped extracting characters because the input sequence has no more characters available (end-of-file reached). |
| failbit | The stream state of is was not good before the call (applies to C++11 and other implementations constructing a sentry object) |
| badbit | Error on stream (such as when this function catches an exception thrown by an internal operation). When set, the integrity of the stream may have been affected. |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// ws manipulator example
#include <iostream> // std::cout, std::noskipws
#include <sstream> // std::istringstream, std::ws
int main () {
char a[10], b[10];
std::istringstream iss ("one \n \t two");
iss >> std::noskipws;
iss >> a >> std::ws >> b;
std::cout << a << ", " << b << '\n';
return 0;
}
one, two