How does istream::operator>>( const char& ) as no such function is implemented?

前端 未结 2 676
灰色年华
灰色年华 2021-01-20 11:16

Looking at istream documentation, you will see that there is no implementation of function istream &operator>>( char& ), but if you compile and ru

2条回答
  •  暖寄归人
    2021-01-20 11:42

    As stated here, operator>> is also implemented as non-member-function of cin.

    Non-member function :

    istream& operator>>( istream& st, char& ch );
    

    There is always the standard stated it explicitly in the section § 27.7.2.2.3 :

    27.7.2.2.3 basic_istream::operator>> [istream::extractors]

    11/ Returns: in.

        template basic_istream& operator>>
            (basic_istream& in, charT& c);
    
        template basic_istream& operator>>
            (basic_istream& in, unsigned char& c);
    
        template basic_istream& operator>>
            (basic_istream& in, signed char& c);
    

提交回复
热议问题