libstdc++: iosfwd Source File

libstdc++

iosfwd
Go to the documentation of this file.
1// <iosfwd> Forward declarations -*- C++ -*-
2
3// Copyright (C) 1997-2026 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file include/iosfwd
26 * This is a Standard C++ Library header.
27 */
28
29//
30// ISO C++ 14882: 27.2 Forward declarations
31//
32
33#ifndef _GLIBCXX_IOSFWD
34#define _GLIBCXX_IOSFWD 1
35
36#ifdef _GLIBCXX_SYSHDR
37#pragma GCC system_header
38#endif
39
40#include <bits/requires_hosted.h> // iostreams
41
42#include <bits/c++config.h>
43#include <bits/stringfwd.h> // For string forward declarations.
44#include <bits/postypes.h>
45
46namespace std _GLIBCXX_VISIBILITY(default)
47{
48_GLIBCXX_BEGIN_NAMESPACE_VERSION
49
50 /**
51 * @defgroup io I/O
52 *
53 * Nearly all of the I/O classes are parameterized on the type of
54 * characters they read and write. (The major exception is ios_base at
55 * the top of the hierarchy.) This is a change from pre-Standard
56 * streams, which were not templates.
57 *
58 * For ease of use and compatibility, all of the basic_* I/O-related
59 * classes are given typedef names for both of the builtin character
60 * widths (wide and narrow). The typedefs are the same as the
61 * pre-Standard names, for example:
62 *
63 * @code
64 * typedef basic_ifstream<char> ifstream;
65 * @endcode
66 *
67 * Because properly forward-declaring these classes can be difficult, you
68 * should not do it yourself. Instead, include the &lt;iosfwd&gt;
69 * header, which contains only declarations of all the I/O classes as
70 * well as the typedefs. Trying to forward-declare the typedefs
71 * themselves (e.g., <code>class ostream;</code>) is not valid ISO C++.
72 *
73 * For more specific declarations, see
74 * https://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html#std.io.objects
75 *
76 * @{
77 */
78 class ios_base;
79
80 template<typename _CharT, typename _Traits = char_traits<_CharT> >
81 class basic_ios;
82
83 template<typename _CharT, typename _Traits = char_traits<_CharT> >
84 class basic_streambuf;
85
86 template<typename _CharT, typename _Traits = char_traits<_CharT> >
87 class basic_istream;
88
89 template<typename _CharT, typename _Traits = char_traits<_CharT> >
90 class basic_ostream;
91
92 template<typename _CharT, typename _Traits = char_traits<_CharT> >
93 class basic_iostream;
94
95
96_GLIBCXX_BEGIN_NAMESPACE_CXX11
97
98 template<typename _CharT, typename _Traits = char_traits<_CharT>,
99 typename _Alloc = allocator<_CharT> >
100 class basic_stringbuf;
101
102 template<typename _CharT, typename _Traits = char_traits<_CharT>,
103 typename _Alloc = allocator<_CharT> >
104 class basic_istringstream;
105
106 template<typename _CharT, typename _Traits = char_traits<_CharT>,
107 typename _Alloc = allocator<_CharT> >
108 class basic_ostringstream;
109
110 template<typename _CharT, typename _Traits = char_traits<_CharT>,
111 typename _Alloc = allocator<_CharT> >
112 class basic_stringstream;
113
114_GLIBCXX_END_NAMESPACE_CXX11
115
116 template<typename _CharT, typename _Traits = char_traits<_CharT> >
117 class basic_filebuf;
118
119 template<typename _CharT, typename _Traits = char_traits<_CharT> >
120 class basic_ifstream;
121
122 template<typename _CharT, typename _Traits = char_traits<_CharT> >
123 class basic_ofstream;
124
125 template<typename _CharT, typename _Traits = char_traits<_CharT> >
126 class basic_fstream;
127
128 template<typename _CharT, typename _Traits = char_traits<_CharT> >
129 class istreambuf_iterator;
130
131 template<typename _CharT, typename _Traits = char_traits<_CharT> >
132 class ostreambuf_iterator;
133
134
135 /// Base class for @c char streams.
136 typedef basic_ios<char> ios;
137
138 /// Base class for @c char buffers.
139 typedef basic_streambuf<char> streambuf;
140
141 /// Base class for @c char input streams.
142 typedef basic_istream<char> istream;
143
144 /// Base class for @c char output streams.
145 typedef basic_ostream<char> ostream;
146
147 /// Base class for @c char mixed input and output streams.
148 typedef basic_iostream<char> iostream;
149
150 /// Class for @c char memory buffers.
151 typedef basic_stringbuf<char> stringbuf;
152
153 /// Class for @c char input memory streams.
154 typedef basic_istringstream<char> istringstream;
155
156 /// Class for @c char output memory streams.
157 typedef basic_ostringstream<char> ostringstream;
158
159 /// Class for @c char mixed input and output memory streams.
160 typedef basic_stringstream<char> stringstream;
161
162 /// Class for @c char file buffers.
163 typedef basic_filebuf<char> filebuf;
164
165 /// Class for @c char input file streams.
166 typedef basic_ifstream<char> ifstream;
167
168 /// Class for @c char output file streams.
169 typedef basic_ofstream<char> ofstream;
170
171 /// Class for @c char mixed input and output file streams.
172 typedef basic_fstream<char> fstream;
173
174#ifdef _GLIBCXX_USE_WCHAR_T
175 /// Base class for @c wchar_t streams.
176 typedef basic_ios<wchar_t> wios;
177
178 /// Base class for @c wchar_t buffers.
179 typedef basic_streambuf<wchar_t> wstreambuf;
180
181 /// Base class for @c wchar_t input streams.
182 typedef basic_istream<wchar_t> wistream;
183
184 /// Base class for @c wchar_t output streams.
185 typedef basic_ostream<wchar_t> wostream;
186
187 /// Base class for @c wchar_t mixed input and output streams.
188 typedef basic_iostream<wchar_t> wiostream;
189
190 /// Class for @c wchar_t memory buffers.
191 typedef basic_stringbuf<wchar_t> wstringbuf;
192
193 /// Class for @c wchar_t input memory streams.
194 typedef basic_istringstream<wchar_t> wistringstream;
195
196 /// Class for @c wchar_t output memory streams.
197 typedef basic_ostringstream<wchar_t> wostringstream;
198
199 /// Class for @c wchar_t mixed input and output memory streams.
200 typedef basic_stringstream<wchar_t> wstringstream;
201
202 /// Class for @c wchar_t file buffers.
203 typedef basic_filebuf<wchar_t> wfilebuf;
204
205 /// Class for @c wchar_t input file streams.
206 typedef basic_ifstream<wchar_t> wifstream;
207
208 /// Class for @c wchar_t output file streams.
209 typedef basic_ofstream<wchar_t> wofstream;
210
211 /// Class for @c wchar_t mixed input and output file streams.
212 typedef basic_fstream<wchar_t> wfstream;
213#endif
214
215#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
216 template<typename _CharT, typename _Traits = char_traits<_CharT>,
217 typename _Allocator = allocator<_CharT>>
218 class basic_syncbuf;
219 template<typename _CharT, typename _Traits = char_traits<_CharT>,
220 typename _Allocator = allocator<_CharT>>
221 class basic_osyncstream;
222
223 using syncbuf = basic_syncbuf<char>;
224 using osyncstream = basic_osyncstream<char>;
225
226#ifdef _GLIBCXX_USE_WCHAR_T
227 using wsyncbuf = basic_syncbuf<wchar_t>;
228 using wosyncstream = basic_osyncstream<wchar_t>;
229#endif
230#endif // C++20 && CXX11_ABI
231
232#if __cplusplus > 202002L
233 template<typename _CharT, typename _Traits = char_traits<_CharT>>
234 class basic_spanbuf;
235 template<typename _CharT, typename _Traits = char_traits<_CharT>>
236 class basic_ispanstream;
237 template<typename _CharT, typename _Traits = char_traits<_CharT>>
238 class basic_ospanstream;
239 template<typename _CharT, typename _Traits = char_traits<_CharT>>
240 class basic_spanstream;
241
242 using spanbuf = basic_spanbuf<char>;
243 using ispanstream = basic_ispanstream<char>;
244 using ospanstream = basic_ospanstream<char>;
245 using spanstream = basic_spanstream<char>;
246
247#ifdef _GLIBCXX_USE_WCHAR_T
248 using wspanbuf = basic_spanbuf<wchar_t>;
249 using wispanstream = basic_ispanstream<wchar_t>;
250 using wospanstream = basic_ospanstream<wchar_t>;
251 using wspanstream = basic_spanstream<wchar_t>;
252#endif
253#endif // C++23
254
255 /** @} */
256
257_GLIBCXX_END_NAMESPACE_VERSION
258} // namespace
259
260#endif /* _GLIBCXX_IOSFWD */
postypes.h
requires_hosted.h
stringfwd.h
c++config.h
std::wifstream
basic_ifstream< wchar_t > wifstream
Class for wchar_t input file streams.
Definition iosfwd:206
std::stringstream
basic_stringstream< char > stringstream
Class for char mixed input and output memory streams.
Definition iosfwd:160
std::wiostream
basic_iostream< wchar_t > wiostream
Base class for wchar_t mixed input and output streams.
Definition iosfwd:188
std::streambuf
basic_streambuf< char > streambuf
Base class for char buffers.
Definition iosfwd:139
std::wstringbuf
basic_stringbuf< wchar_t > wstringbuf
Class for wchar_t memory buffers.
Definition iosfwd:191
std::ostream
basic_ostream< char > ostream
Base class for char output streams.
Definition iosfwd:145
std::ifstream
basic_ifstream< char > ifstream
Class for char input file streams.
Definition iosfwd:166
std::iostream
basic_iostream< char > iostream
Base class for char mixed input and output streams.
Definition iosfwd:148
std::wios
basic_ios< wchar_t > wios
Base class for wchar_t streams.
Definition iosfwd:176
std::istringstream
basic_istringstream< char > istringstream
Class for char input memory streams.
Definition iosfwd:154
std::wstreambuf
basic_streambuf< wchar_t > wstreambuf
Base class for wchar_t buffers.
Definition iosfwd:179
std::wistringstream
basic_istringstream< wchar_t > wistringstream
Class for wchar_t input memory streams.
Definition iosfwd:194
std::wfstream
basic_fstream< wchar_t > wfstream
Class for wchar_t mixed input and output file streams.
Definition iosfwd:212
std::ofstream
basic_ofstream< char > ofstream
Class for char output file streams.
Definition iosfwd:169
std::wostringstream
basic_ostringstream< wchar_t > wostringstream
Class for wchar_t output memory streams.
Definition iosfwd:197
std::istream
basic_istream< char > istream
Base class for char input streams.
Definition iosfwd:142
std::wostream
basic_ostream< wchar_t > wostream
Base class for wchar_t output streams.
Definition iosfwd:185
std::wistream
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
Definition iosfwd:182
std::filebuf
basic_filebuf< char > filebuf
Class for char file buffers.
Definition iosfwd:163
std::wfilebuf
basic_filebuf< wchar_t > wfilebuf
Class for wchar_t file buffers.
Definition iosfwd:203
std::wofstream
basic_ofstream< wchar_t > wofstream
Class for wchar_t output file streams.
Definition iosfwd:209
std::fstream
basic_fstream< char > fstream
Class for char mixed input and output file streams.
Definition iosfwd:172
std::wstringstream
basic_stringstream< wchar_t > wstringstream
Class for wchar_t mixed input and output memory streams.
Definition iosfwd:200
std::ios
basic_ios< char > ios
Base class for char streams.
Definition iosfwd:136
std::ostringstream
basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition iosfwd:157
std::stringbuf
basic_stringbuf< char > stringbuf
Class for char memory buffers.
Definition iosfwd:151
std
ISO C++ entities toplevel namespace is std.
std::basic_filebuf
The actual work of input and output (for files).
Definition fstream:93
std::basic_ifstream
Controlling input for files.
Definition fstream:536
std::basic_ofstream
Controlling output for files.
Definition fstream:809
std::basic_fstream
Controlling input and output for files.
Definition fstream:1084
std::basic_ios
Template class basic_ios, virtual base class for all stream classes.
Definition basic_ios.h:71
std::basic_streambuf
The actual work of input and output (interface).
Definition streambuf:127
std::basic_istream
Template class basic_istream.
Definition istream:67
std::basic_ostream
Template class basic_ostream.
Definition ostream.h:67
std::basic_iostream
Template class basic_iostream.
Definition istream:999
std::basic_stringbuf
The actual work of input and output (for std::string).
Definition sstream:88
std::basic_istringstream
Controlling input for std::string.
Definition sstream:609
std::basic_ostringstream
Controlling output for std::string.
Definition sstream:875
std::basic_stringstream
Controlling input and output for std::string.
Definition sstream:1141
std::istreambuf_iterator
Provides input iterator semantics for streambufs.
Definition streambuf_iterator.h:59
std::ostreambuf_iterator
Provides output iterator semantics for streambufs.
Definition streambuf_iterator.h:253
std::ios_base
The base of the I/O class hierarchy.
Definition ios_base.h:266