tags:

views:

176

answers:

1

The "method" implementation says istringstream get

int get();
Extracts a character from the stream and returns its value (casted to an integer).

I wanted to see its implementation.

Edit:Removed the part which I am trying to port

+2  A: 

You will find std::istringstream in the header <sstream>. But not the get() method. The get() member is inherited from the basic_istream<_Elem, _Traits> template which you can find in the header . Here's the implementation, from my VS2005 installation:

int_type __CLR_OR_THIS_CALL get()
 { // extract a metacharacter
 int_type _Meta = 0;
 ios_base::iostate _State = ios_base::goodbit;
 _Chcount = 0;
 const sentry _Ok(*this, true);

 if (!_Ok)
  _Meta = _Traits::eof(); // state not okay, return EOF
 else
  { // state okay, extract a character
  _TRY_IO_BEGIN
  _Meta = _Myios::rdbuf()->sbumpc();

  if (_Traits::eq_int_type(_Traits::eof(), _Meta))
   _State |= ios_base::eofbit | ios_base::failbit; // end of file
  else
   ++_Chcount; // got a character, count it
  _CATCH_IO_END
  }

 _Myios::setstate(_State);
 return (_Meta);
 }
dirkgently