std::basic_istream<CharT,Traits>::operator>> (3) - Linux Manuals
std::basic_istream<CharT,Traits>::operator>>: std::basic_istream<CharT,Traits>::operator>>
NAME
std::basic_istream<CharT,Traits>::operator>> - std::basic_istream<CharT,Traits>::operator>>
Synopsis
basic_istream& operator>>( short& value ); (1)
basic_istream& operator>>( unsigned short& value );
basic_istream& operator>>( int& value ); (2)
basic_istream& operator>>( unsigned int& value );
basic_istream& operator>>( long& value ); (3)
basic_istream& operator>>( unsigned long& value );
basic_istream& operator>>( long long& value ); (4) (since C++11)
basic_istream& operator>>( unsigned long long& value );
basic_istream& operator>>( float& value );
basic_istream& operator>>( double& value ); (5)
basic_istream& operator>>( long double& value );
basic_istream& operator>>( bool& value ); (6)
basic_istream& operator>>( void*& value ); (7)
basic_istream& operator>>( std::ios_base& (*func)(std::ios_base&) ); (8)
basic_istream& operator>>( std::basic_ios<CharT,Traits>& (*func)(std::basic_ios<CharT,Traits>&) ); (9)
basic_istream& operator>>( basic_istream& (*func)(basic_istream&) ); (10)
basic_istream& operator>>( std::basic_streambuf<CharT,Traits>* sb ); (11)
1-4) Behaves as a FormattedInputFunction. After constructing and checking the sentry object, which may skip leading whitespace, extracts an integer value by calling std::num_get::get()
5) Behaves as a FormattedInputFunction. After constructing and checking the sentry object, which may skip leading whitespace, extracts a floating point value by calling std::num_get::get()
6) Behaves as a FormattedInputFunction. After constructing and checking the sentry object, which may skip leading whitespace, extracts bool value by calling std::num_get::get()
7) Behaves as a FormattedInputFunction. After constructing and checking the sentry object, which may skip leading whitespace, extracts a generic pointer value by calling std::num_get::get()
8-10) Calls func(*this), where func is an I/O manipulator.
11) Behaves as an UnformattedInputFunction. After constructing and checking the sentry object, extracts all data from the input stream and stores it to sb. The extraction stops if one of the following conditions are met:
In either case, stores the number of characters extracted in the member variable accessed by subsequent calls to gcount(). If sb is a null pointer or if no characters were inserted into sb, calls setstate(failbit) (which may throw std::ios_base::failure if enabled).
If extraction fails (e.g. if a letter was entered where a digit is expected), value is left unmodified and failbit is set. (until C++11)
If extraction fails, zero is written to value and failbit is set. If extraction results in the value too large or too small to fit in value, std::numeric_limits<T>::max() or std::numeric_limits<T>::min() is written and failbit flag is set. (since C++11)
Parameters
value - reference to an integer or floating-point value to store the extracted value to
func - pointer to I/O manipulator function
sb - pointer to the streambuffer to write all the data to
Return value
1-9,11) *this
10) func(*this)
Example
// Run this code
Output:
See also
operator>>(std::basic_istream) (function template)
operator<< (function template)
operator>>
operator<< (function template)
operator>>
operator<< (function template)
operator>>