istreambuf_iterator::istreambuf_iterator

Construye un istreambuf_iterator inicializarlo para leer los caracteres del flujo de entrada.

istreambuf_iterator(
   streambuf_type* _Strbuf = 0
) throw( );
istreambuf_iterator(
   istream_type& _Istr
) throw( );

Parámetros

  • _Strbuf
    El búfer de flujo de entrada al que se está asociando istreambuf_iterator .

  • _Istr
    El flujo de entrada al que se está asociando istreambuf_iterator .

Comentarios

El primer constructor inicializa el puntero de secuencia-búfer de entrada con _Strbuf.El segundo constructor inicializa el puntero de secuencia-búfer de entrada con _Istr.rdbuf, y después intenta finalmente extraer y almacenar un objeto de CharTypeescrito.

Ejemplo

// istreambuf_iterator_istreambuf_iterator.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <algorithm>
#include <iostream>

int main( )
{
   using namespace std;

   // Following declarations will not compile:
   istreambuf_iterator<char>::istream_type &istrm = cin;
   istreambuf_iterator<char>::streambuf_type *strmbf = cin.rdbuf( );

   cout << "(Try the example: 'Oh what a world!'\n"
      << " then an Enter key to insert into the output,\n"
      << " & use a ctrl-Z Enter key combination to exit): ";
   istreambuf_iterator<char> charReadIn ( cin );
   ostreambuf_iterator<char> charOut ( cout );

   // Used in conjunction with replace_copy algorithm
   // to insert into output stream and replace spaces
   // with hyphen-separators
   replace_copy ( charReadIn , istreambuf_iterator<char>( ),
      charOut , ' ' , '-' );
}
  El oh ¡qué mundo! 
  El ¡oh qué mundo! 
(Pruebe el ejemplo: “Oh qué mundo!” a continuación una tecla ENTRAR a insertar en la salida, y utilice una combinación de teclas enter Ctrl - z para salir): El ¡oh qué mundo! el Oh-qué-uno-mundo! ^Z

Requisitos

encabezado: <iterador>

espacio de nombres: std

Vea también

Referencia

istreambuf_iterator Class

Biblioteca de plantillas estándar