27 Input/output library [input.output]

27.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 [tab:iostreams.lib.summary].

Table 121 — Input/output library summary
Subclause Header(s)
[iostreams.requirements] Requirements
[iostream.forward] Forward declarations <iosfwd>
[iostream.objects] Standard iostream objects <iostream>
[iostreams.base] Iostreams base classes <ios>
[stream.buffers] Stream buffers <streambuf>
[iostream.format] Formatting and manipulators <istream>
<ostream>
<iomanip>
[string.streams] String streams <sstream>
[file.streams] File streams <fstream>
<cstdio>
<cinttypes>

Figure [fig:streampos] 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 [non-normative]