iostream
classes are just wrappers around I/O buffers. The iostream
itself doesn't do a whole lot… mainly, it the provides operator>>
formatting operators. The buffer is provided by an object derived from basic_streambuf
, which you can get and set using rdbuf()
.
basic_streambuf
is an abstract base with a number of virtual functions which are overridden to provide a uniform interface for reading/writing files, strings, etc. The function basic_ostream<…>::operator<<( basic_streambuf<…> )
is defined to keep reading through the buffer until the underlying data source is exhausted.
iostream
is a terrible mess, though.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…