2009-03-01 5 views
0

을 "얻을" "방법"구현 나는 그것의 구현을보고 싶어 istringstream getistringstream 메소드 구현

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

말한다.

편집 : 제거 당신은 헤더 <sstream>에서 std::istringstream 찾을 I 포트

답변

2

에 노력하고 부분. 그러나 get() 방법은 아닙니다. get() 회원은 헤더에서 찾을 수있는 basic_istream<_Elem, _Traits> 템플릿에서 상속됩니다. 다음은 VS2005 설치의 구현입니다.

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); 
    } 
관련 문제