basic_istream::operator>>

Chiama una funzione sul flusso di input oppure legge i dati formattati dal flusso di input.

basic_istream& operator>>(
   basic_istream& (*_Pfn)(basic_istream&)
);
basic_istream& operator>>(
   ios_base& (*_Pfn)(ios_base&)
);
basic_istream& operator>>(
   basic_ios<Elem, Tr>& (*_Pfn)(basic_ios<Elem, Tr>&))
;
basic_istream& operator>>(
   basic_streambuf<Elem, Tr> *_Strbuf
);
basic_istream& operator>>(
   bool& _Val
);
basic_istream& operator>>(
   short& _Val
);
basic_istream& operator>>(
   unsigned short& _Val
);
basic_istream& operator>>(
   int& _Val
);
basic_istream& operator>>(
   unsigned int& _Val
);
basic_istream& operator>>(
   long& _Val
);
basic_istream& operator>>(
   unsigned long& _Val
);
basic_istream& operator>>(
   long long& _Val
);
basic_istream& operator>>(
   unsigned long long& _Val
);
basic_istream& operator>>(
   void *& _Val
);
basic_istream& operator>>(
   float& _Val
);
basic_istream& operator>>(
   double& _Val
);
basic_istream& operator>>(
   long double& _Val
);

Parametri

  • _Pfn
    Puntatore a funzione.

  • _Strbuf
    Un oggetto di tipo stream_buf.

  • _Val
    Il valore da leggere dal flusso.

Valore restituito

Il flusso***this**().

Note

L'intestazione <istream> definisce inoltre numerosi operatori globali di estrazione.Per ulteriori informazioni, vedere operator>> (<istream>).

La prima funzione membro assicura che un'espressione del form istr >> ws chiamare la WS(istr) e quindi restituisce *this.Nella seconda e la terza funzioni garantiscono che altri manipolatori, come esadecimali, si comportino nello stesso modo.Le funzioni rimanenti costituiscono le funzioni di input formattate.

La funzione:

basic_istream& operator>>(
    basic_streambuf<Elem, Tr> *_Strbuf);

estrae gli elementi, se il _Strbuf non è un puntatore null e li inserisce in _Strbuf.Le interruzioni di estrazione su fine del file.Si interrompe senza estrarre l'elemento in questione, se un inserimento non riesce o genera un'eccezione (che viene intercettata ma non genera).Se la funzione non viene estratto elementi, chiama setstate(failbit).Tuttavia, la funzione restituisce *this.

La funzione:

basic_istream& operator>>(bool& _Val);

estrae un campo e lo converte in un valore boolean chiamando use_facet <num_get<Elem, INIZIALIZZAZIONE> (getloc).ottenere(INIZIALIZZAZIONE( rdbuf), Init(0), *this, getloc, _Val).In questo caso, INIZIALIZZAZIONE viene definito come istreambuf_iterator<Elem, Tr>.La funzione restituisce *this.

Le funzioni:

basic_istream& operator>>(short& _Val);
basic_istream& operator>>(unsigned short& _Val);
basic_istream& operator>>(int& _Val);
basic_istream& operator>>(unsigned int& _Val);
basic_istream& operator>>(long& _Val);
basic_istream& operator>>(unsigned long& _Val);

basic_istream& operator>>(long long& _Val);
basic_istream& operator>>(unsigned long long& _Val);

basic_istream& operator>>(void *& _Val);

ogni estrae un campo e lo converte in un valore numerico chiamando use_facet<num_get<Elem, INIZIALIZZAZIONE> (getloc).ottenere(INIZIALIZZAZIONE( rdbuf), Init(0), *this, getloc, _Val).In questo caso, INIZIALIZZAZIONE definito come istreambuf_iterator<Elem, Tr> e _Val è di tipo LONG*,unsigned long,* o void * in base alle necessità.

Se il valore convertito non può essere rappresentato come tipo _Val, le chiamate di funzione setstate(failbit).Tuttavia, la funzione restituisce *this.

Le funzioni:

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

ogni estrae un campo e lo converte in un valore numerico chiamando use_facet<num_get<Elem, INIZIALIZZAZIONE> (getloc).get(INIZIALIZZAZIONE( rdbuf), Init(0), *this, getloc, _Val).In questo caso, INIZIALIZZAZIONE definito come istreambuf_iterator<Elem, Tr> e _Val è di tipo double o long double in base alle necessità.

Se il valore convertito non può essere rappresentato come tipo _Val, le chiamate di funzione setstate(failbit).Tuttavia, restituisce *this.

Esempio

// istream_basic_istream_op_is.cpp
// compile with: /EHsc
#include <iostream>

using namespace std;

ios_base& hex2( ios_base& ib ) 
{
   ib.unsetf( ios_base::dec );
   ib.setf( ios_base::hex );
   return ib;
}

basic_istream<char, char_traits<char> >& somefunc(basic_istream<char, char_traits<char> > &i)
{
   if ( i == cin ) 
   {
      cerr << "i is cin" << endl;
   }
   return i;
}

int main( ) 
{
   int i = 0;
   cin >> somefunc;
   cin >> i;
   cout << i << endl;
   cin >> hex2;
   cin >> i;
   cout << i << endl;
}

Input

10
10

Esempio di output

i is cin
10
10
10
16

Requisiti

intestazione: <istream>

Spazio dei nomi: deviazione standard

Vedere anche

Riferimenti

basic_istream Class

operator>> (<istream>)

programmazione di iostream

convenzioni di iostream