1// <iosfwd> Forward declarations -*- C++ -*-
3// Copyright (C) 1997-2025 Free Software Foundation, Inc.
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)
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.
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.
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/>.
25/** @file include/iosfwd
26 * This is a Standard C++ Library header.
30// ISO C++ 14882: 27.2 Forward declarations
33#ifndef _GLIBCXX_IOSFWD
34#define _GLIBCXX_IOSFWD 1
37#pragma GCC system_header
40#include <bits/requires_hosted.h> // iostreams
42#include <bits/c++config.h>
43#include <bits/stringfwd.h> // For string forward declarations.
44#include <bits/postypes.h>
46namespace std _GLIBCXX_VISIBILITY(default)
48_GLIBCXX_BEGIN_NAMESPACE_VERSION
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.
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:
64 * typedef basic_ifstream<char> ifstream;
67 * Because properly forward-declaring these classes can be difficult, you
68 * should not do it yourself. Instead, include the <iosfwd>
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++.
73 * For more specific declarations, see
74 * https://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html#std.io.objects
80 template<typename _CharT, typename _Traits = char_traits<_CharT> >
83 template<typename _CharT, typename _Traits = char_traits<_CharT> >
84 class basic_streambuf;
86 template<typename _CharT, typename _Traits = char_traits<_CharT> >
89 template<typename _CharT, typename _Traits = char_traits<_CharT> >
92 template<typename _CharT, typename _Traits = char_traits<_CharT> >
96_GLIBCXX_BEGIN_NAMESPACE_CXX11
98 template<typename _CharT, typename _Traits = char_traits<_CharT>,
99 typename _Alloc = allocator<_CharT> >
100 class basic_stringbuf;
102 template<typename _CharT, typename _Traits = char_traits<_CharT>,
103 typename _Alloc = allocator<_CharT> >
104 class basic_istringstream;
106 template<typename _CharT, typename _Traits = char_traits<_CharT>,
107 typename _Alloc = allocator<_CharT> >
108 class basic_ostringstream;
110 template<typename _CharT, typename _Traits = char_traits<_CharT>,
111 typename _Alloc = allocator<_CharT> >
112 class basic_stringstream;
114_GLIBCXX_END_NAMESPACE_CXX11
116 template<typename _CharT, typename _Traits = char_traits<_CharT> >
119 template<typename _CharT, typename _Traits = char_traits<_CharT> >
120 class basic_ifstream;
122 template<typename _CharT, typename _Traits = char_traits<_CharT> >
123 class basic_ofstream;
125 template<typename _CharT, typename _Traits = char_traits<_CharT> >
128 template<typename _CharT, typename _Traits = char_traits<_CharT> >
129 class istreambuf_iterator;
131 template<typename _CharT, typename _Traits = char_traits<_CharT> >
132 class ostreambuf_iterator;
135 /// Base class for @c char streams.
136 typedef basic_ios<char> ios;
138 /// Base class for @c char buffers.
139 typedef basic_streambuf<char> streambuf;
141 /// Base class for @c char input streams.
142 typedef basic_istream<char> istream;
144 /// Base class for @c char output streams.
145 typedef basic_ostream<char> ostream;
147 /// Base class for @c char mixed input and output streams.
148 typedef basic_iostream<char> iostream;
150 /// Class for @c char memory buffers.
151 typedef basic_stringbuf<char> stringbuf;
153 /// Class for @c char input memory streams.
154 typedef basic_istringstream<char> istringstream;
156 /// Class for @c char output memory streams.
157 typedef basic_ostringstream<char> ostringstream;
159 /// Class for @c char mixed input and output memory streams.
160 typedef basic_stringstream<char> stringstream;
162 /// Class for @c char file buffers.
163 typedef basic_filebuf<char> filebuf;
165 /// Class for @c char input file streams.
166 typedef basic_ifstream<char> ifstream;
168 /// Class for @c char output file streams.
169 typedef basic_ofstream<char> ofstream;
171 /// Class for @c char mixed input and output file streams.
172 typedef basic_fstream<char> fstream;
174#ifdef _GLIBCXX_USE_WCHAR_T
175 /// Base class for @c wchar_t streams.
176 typedef basic_ios<wchar_t> wios;
178 /// Base class for @c wchar_t buffers.
179 typedef basic_streambuf<wchar_t> wstreambuf;
181 /// Base class for @c wchar_t input streams.
182 typedef basic_istream<wchar_t> wistream;
184 /// Base class for @c wchar_t output streams.
185 typedef basic_ostream<wchar_t> wostream;
187 /// Base class for @c wchar_t mixed input and output streams.
188 typedef basic_iostream<wchar_t> wiostream;
190 /// Class for @c wchar_t memory buffers.
191 typedef basic_stringbuf<wchar_t> wstringbuf;
193 /// Class for @c wchar_t input memory streams.
194 typedef basic_istringstream<wchar_t> wistringstream;
196 /// Class for @c wchar_t output memory streams.
197 typedef basic_ostringstream<wchar_t> wostringstream;
199 /// Class for @c wchar_t mixed input and output memory streams.
200 typedef basic_stringstream<wchar_t> wstringstream;
202 /// Class for @c wchar_t file buffers.
203 typedef basic_filebuf<wchar_t> wfilebuf;
205 /// Class for @c wchar_t input file streams.
206 typedef basic_ifstream<wchar_t> wifstream;
208 /// Class for @c wchar_t output file streams.
209 typedef basic_ofstream<wchar_t> wofstream;
211 /// Class for @c wchar_t mixed input and output file streams.
212 typedef basic_fstream<wchar_t> wfstream;
215#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
216 template<typename _CharT, typename _Traits = char_traits<_CharT>,
217 typename _Allocator = allocator<_CharT>>
219 template<typename _CharT, typename _Traits = char_traits<_CharT>,
220 typename _Allocator = allocator<_CharT>>
221 class basic_osyncstream;
223 using syncbuf = basic_syncbuf<char>;
224 using osyncstream = basic_osyncstream<char>;
226#ifdef _GLIBCXX_USE_WCHAR_T
227 using wsyncbuf = basic_syncbuf<wchar_t>;
228 using wosyncstream = basic_osyncstream<wchar_t>;
230#endif // C++20 && CXX11_ABI
232#if __cplusplus > 202002L
233 template<typename _CharT, typename _Traits = char_traits<_CharT>>
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;
242 using spanbuf = basic_spanbuf<char>;
243 using ispanstream = basic_ispanstream<char>;
244 using ospanstream = basic_ospanstream<char>;
245 using spanstream = basic_spanstream<char>;
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>;
257_GLIBCXX_END_NAMESPACE_VERSION
260#endif /* _GLIBCXX_IOSFWD */