std::ws (3) - Linux Manuals
std::ws: std::ws
Command to display std::ws
manual in Linux: $ man 3 std::ws
NAME
std::ws - std::ws
Synopsis
Defined in header <istream>
template< class CharT, class Traits >
std::basic_istream<CharT,Traits>& ws( std::basic_istream<CharT, Traits>& is );
Discards leading whitespace from an input stream.
Behaves as an UnformattedInputFunction, except that is.gcount() is not modified. After constructing and checking the sentry object, extracts characters from the stream and discards them until any one of the following conditions occurs:
* end of file condition occurs in the input sequence (in which case the function calls setstate(eofbit) but does not set failbit; this does not apply if the eofbit is already set on is prior to the call to ws, in which case the construction of the sentry object would set failbit).
* the next available character c in the input sequence is not whitespace as determined by std::isspace(c, is.getloc()). The non-whitespace character is not extracted.
This is an input-only I/O manipulator, it may be called with an expression such as in >> std::ws for any in of type std::basic_istream.
Parameters
is - reference to input stream
Return value
is (reference to the stream after extraction of consecutive whitespace)
Notes
If eofbit is set on the stream prior to the call, the construction of the sentry object will set failbit.
Example
// Run this code
#include <iostream>
#include <istream>
#include <sstream>
#include <string>
int main()
{
std::istringstream s(" this is a test");
std::string line;
std::getline(s >> std::ws, line);
std::cout << "ws + getline returns: \"" << line << "\"\n";
}
Output:
ws + getline returns: "this is a test"
See also
extracts and discards characters until the given character is found
ignore (public member function of std::basic_istream<CharT,Traits>)
Pages related to std::ws
- std::wscanf,std::fwscanf,std::swscanf (3) - std::wscanf,std::fwscanf,std::swscanf
- std::wstreambuf (3) - std::basic_streambuf
- std::wstring (3) - std::basic_string
- std::wstring_convert (3) - std::wstring_convert
- std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::converted (3) - std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::converted
- std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::from_bytes (3) - std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::from_bytes
- std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::state (3) - std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::state
- std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::to_bytes (3) - std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::to_bytes
- std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::wstring_convert (3) - std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::wstring_convert
- std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::~wstring_convert (3) - std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::~wstring_convert
- std::wstringbuf (3) - std::basic_stringbuf
- std::wstringstream (3) - std::basic_stringstream