Share via


istreambuf_iterator::operator++

Either returns the next character from the input stream or copies the object before incrementing it and returns the copy.

istreambuf_iterator<CharType, Traits>& operator++( );
istreambuf_iterator<CharType, Traits> operator++( int );

Return Value

An istreambuf_iterator or a reference to an istreambuf_iterator.

Remarks

The first operator eventually attempts to extract and store an object of type CharType from the associated input stream. The second operator makes a copy of the object, increments the object, and then returns the copy.

Example

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

int main( )
{
   using namespace std;

   cout << "Type string of characters & enter to output it,\n"
      << " with stream buffer iterators,(try: 'I'll be back.')\n"
      << " repeat as many times as desired,\n" 
      << " then keystroke ctrl-Z Enter to exit program: ";
   istreambuf_iterator<char> inpos ( cin );
   istreambuf_iterator<char> endpos;
   ostreambuf_iterator<char> outpos ( cout );
   while ( inpos != endpos )
   {
      *outpos = *inpos;
      ++inpos;   //Increment istreambuf_iterator
      ++outpos;
   }
}
  I'll be back.

FakePre-b3317a80a95f439f8e540db68696562e-234a3175d79147378b4bae72a082543e

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

istreambuf_iterator Class

Standard Template Library

Other Resources

istreambuf_iterator Members