How does “std::cout << std::endl;” compile?

后端 未结 4 2171
北荒
北荒 2020-12-10 12:36

Most IO stream manipulators are regular functions with the following signature:

std::ios_base& func( std::ios_base& str );

However

4条回答
  •  情歌与酒
    2020-12-10 13:24

    Because basic_ostream has a templated overload of operator<< that expects just such a function pointer:

    basic_ostream& operator<<(basic_ios& (*pf)(basic_ios&));
    

提交回复
热议问题