How does std::endl not use any brackets if it is a function?

后端 未结 3 1667
星月不相逢
星月不相逢 2020-12-14 08:21

The question is pretty much in the title. According to C++ Reference, std::endl is actually a function. Looking at its declaration in

3条回答
  •  鱼传尺愫
    2020-12-14 08:44

    Though it's a function [template], standard stream manipulators are designed to be sent to streams as function pointers (or functor object references). Inserting the result of a function call won't give you anything but the value that results from that function call.

    This means that you stream the functor itself (f), rather than the result of calling it (f()).

提交回复
热议问题