What does ifstream::rdbuf() actually do?

前端 未结 3 1446
不知归路
不知归路 2020-12-06 04:45

I have the following code and it works pretty good (other than the fact that it\'s pretty slow, but I don\'t care much about that). It doesn\'t seem intuitive that this woul

3条回答
  •  抹茶落季
    2020-12-06 05:22

    Yes, it's specified in the standard and it's actually quite simple. rdbuf() just returns a pointer to the underlying basic_streambuf object for the given [io]stream object.

    basic_ostream<...> has an overload for operator<< for a pointer to basic_streambuf<...> which writes out the contents of the basic_streambuf<...>.

提交回复
热议问题