Most of the classes in the library are actually very generalized class templates. Each template can operate on various character types, and even the operations themselves, such as how two characters are compared for equality, can be customized. However, the majority of code needs to do input and output operations using only one or two character types, thus most of the time the functionality is accessed through several
typedefs, which specify names for commonly used combinations of template and character type. For example, basic_fstream refers to the generic class template that implements input/output operations on file streams. It is usually used as fstream which is an alias for basic_fstream>, or, in other words, basic_fstream working on characters of type char with the default character operation set. The classes in the library could be divided into roughly two categories: abstractions and implementations. Classes, that fall into abstractions category, provide an interface which is sufficient for working with any type of a stream. The code using such classes doesn't depend on the exact location the data is read from or is written to. For example, such code could write data to a file, a memory buffer or a web socket without a recompilation. The implementation classes inherit the abstraction classes and provide an implementation for concrete type of data source or sink. The library provides implementations only for file-based streams and memory buffer-based streams. The classes in the library could also be divided into two groups by whether it implements low-level or high-level operations. The classes that deal with low-level stuff are called stream buffers. They operate on characters without providing any formatting functionality. These classes are very rarely used directly. The high-level classes are called streams and provide various formatting capabilities. They are built on top of stream buffers. The following table lists and categorizes all classes provided by the input-output library.
Header files The classes of the input/output library reside in several headers. • contains the definitions of std::ios_base and std::basic_ios classes, that manage formatting information and the associated stream-buffer. • contains the definition of std::basic_istream class template, which implements formatted input. • contains the definition of std::basic_ostream class template, which implements formatted output. • contains the definition of std::basic_iostream class template, which implements formatted input and output, and includes , and . • contains the definitions of std::basic_ifstream, std::basic_ofstream and std::basic_fstream class templates which implement formatted input, output and input/output on file streams. • contains the definitions of std::basic_istringstream, std::basic_ostringstream and std::basic_stringstream class templates which implement formatted input, output and input/output on string-based streams. • contains formatting manipulators. • contains forward declarations of all classes in the input/output library. • provides improved input/output devices and streams for char[]. These use a std::span to the underlying buffer. This header supersedes the former . • provides synchronised output devices and streams. • contains format functions such as std::format() and the definition of classes formatter, range_formatter, etc. and concept formattable. • contains the print functions, allowing for the printing of formatted strings to any output or file stream. It contains std::print() and std::println(), where std::println() behaves the same way as std::print(), except that each print is terminated by an additional new line. was used for char[] input/output devices and streams. It is superseded by using std::stringstream and the header, and was removed in
C++26. ==Stream buffers==