Share via


basic_istream::operator>>

basic_istream::operator>> >">

basic_istream& operator>>(
    basic_istream& (*pf)(basic_istream&));
basic_istream& operator>>(
    basic_ios<E, T>& (*pf)(basic_ios<E, T>&));
basic_istream& operator>>(
    ios_base<E, T>& (*pf)(ios_base<E, T>&));
basic_istream& operator>>(
    basic_streambuf<E, T> *sb);
basic_istream& operator>>(bool& n);
basic_istream& operator>>(short& n);
basic_istream& operator>>(unsigned short& n);
basic_istream& operator>>(int& n);
basic_istream& operator>>(unsigned int& n);
basic_istream& operator>>(long& n);
basic_istream& operator>>(unsigned long& n);
basic_istream& operator>>(void *& n);
basic_istream& operator>>(float& n);
basic_istream& operator>>(double& n);
basic_istream& operator>>(long double& n);

The first member function ensures that an expression of the form istr >>: ws calls ws(istr), then returns *this. The second and third functions ensure that other manipulators, such as hex, behave similarly. The remaining functions constitute the formatted input functions.

The function:

basic_istream& operator>>(
    basic_streambuf<E, T> *sb);

extracts elements, if sb is not a null pointer, and inserts them into sb. Extraction stops on end-of-file. It also stops, without extracting the element in question, if an insertion fails or throws an exception (which is caught but not rethrown). If the function extracts no elements, it calls setstate(failbit). In any case, the function returns *this.

The function:

basic_istream& operator>>(bool& n);

extracts a field and converts it to a Boolean value by calling use_facet<num_get<E, InIt>(getloc()).get(InIt( rdbuf()), Init(0), *this, getloc(), n). Here, InIt is defined as istreambuf_iterator<E, T>. The function returns *this.

The functions:

basic_istream& operator>>(short& n);
basic_istream& operator>>(unsigned short& n);
basic_istream& operator>>(int& n);
basic_istream& operator>>(unsigned int& n);
basic_istream& operator>>(long& n);
basic_istream& operator>>(unsigned long& n);
basic_istream& operator>>(void *& n);

each extract a field and convert it to a numeric value by calling use_facet<num_get<E, InIt>(getloc()).get(InIt( rdbuf()), Init(0), *this, getloc(), x). Here, InIt is defined as istreambuf_iterator<E, T>, and x has type long,unsigned long, or void * as needed. If the converted value cannot be represented as the type of n, the function calls setstate(failbit). In any case, it returns *this.

The functions:

basic_istream& operator>>(float& n);
basic_istream& operator>>(double& n);
basic_istream& operator>>(long double& n);

each extract a field and convert it to a numeric value by calling use_facet<num_get<E, InIt>(getloc()).get(InIt( rdbuf()), Init(0), *this, getloc(), x). Here, InIt is defined as istreambuf_iterator<E, T>, and x has type double or long double as needed. If the converted value cannot be represented as the type of n, the function calls setstate(failbit). In any case, it returns *this.