29 Input/output library [input.output]

29.1 General [input.output.general]

This Clause describes components that C++ programs may use to perform input/output operations.
The following subclauses describe requirements for stream parameters, and components for forward declarations of iostreams, predefined iostreams objects, base iostreams classes, stream buffering, stream formatting and manipulators, string streams, and file streams, as summarized in Table 115.
Table 115: Input/output library summary   [tab:iostreams.summary]
Subclause
Header
Requirements
Forward declarations
<iosfwd>
Standard iostream objects
<iostream>
Iostreams base classes
<ios>
Stream buffers
<streambuf>
Formatting and manipulators
<iomanip>, <istream>, <ostream>
String streams
<sstream>
File streams
<fstream>
Synchronized output streams
<syncstream>
File systems
<filesystem>
C library files
<cstdio>, <cinttypes>
Note
:
Figure 7 illustrates relationships among various types described in this clause.
A line from A to B indicates that A is an alias (e.g., a typedef) for B or that A is defined in terms of B.
🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io char_traits<char> ::pos_type 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io streampos 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io iostreams.limits.pos 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io char_traits<wchar_t> ::pos_type 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io wstreampos 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io iostreams.limits.pos 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io fpos<mbstate_t> 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io iostream.forward 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io iostream.forward 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io char_traits<char> ::off_type 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io streamoff 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io iostreams.limits.pos 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io char_traits<wchar_t> ::off_type 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io iostreams.limits.pos 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io signed integer type sufficient for O/S maximum file size 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io stream.types 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io streamsize 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io signed integer type represents characters xfered or buffer sizes 🌐 [input.output.general]figstreampostraits_pos_type_charstreampostraits_pos_type_char->streampostraits_pos_type_wchar_twstreampostraits_pos_type_wchar_t->wstreamposfposstreampos->fposwstreampos->fpostraits_off_type_charstreamofftraits_off_type_char->streamofftraits_off_type_wchar_ttraits_off_type_wchar_t->streamoffstreamoff_typestreamoff->streamoff_typestreamsizestreamsize_typestreamsize->streamsize_type - timsong-cpp.github.io stream.types
Figure 7: Stream position, offset, and size types  [fig:iostreams.streampos]
β€” end note
 ]