llvm-project
195 строк · 7.8 Кб
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_OSTREAM
11#define _LIBCPP_OSTREAM
12
13/*
14ostream synopsis
15
16template <class charT, class traits = char_traits<charT> >
17class basic_ostream
18: virtual public basic_ios<charT,traits>
19{
20public:
21// types (inherited from basic_ios (27.5.4)):
22typedef charT char_type;
23typedef traits traits_type;
24typedef typename traits_type::int_type int_type;
25typedef typename traits_type::pos_type pos_type;
26typedef typename traits_type::off_type off_type;
27
28// 27.7.2.2 Constructor/destructor:
29explicit basic_ostream(basic_streambuf<char_type,traits>* sb);
30basic_ostream(basic_ostream&& rhs);
31virtual ~basic_ostream();
32
33// 27.7.2.3 Assign/swap
34basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14
35basic_ostream& operator=(basic_ostream&& rhs);
36void swap(basic_ostream& rhs);
37
38// 27.7.2.4 Prefix/suffix:
39class sentry;
40
41// 27.7.2.6 Formatted output:
42basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
43basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT,traits>&));
44basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
45basic_ostream& operator<<(bool n);
46basic_ostream& operator<<(short n);
47basic_ostream& operator<<(unsigned short n);
48basic_ostream& operator<<(int n);
49basic_ostream& operator<<(unsigned int n);
50basic_ostream& operator<<(long n);
51basic_ostream& operator<<(unsigned long n);
52basic_ostream& operator<<(long long n);
53basic_ostream& operator<<(unsigned long long n);
54basic_ostream& operator<<(float f);
55basic_ostream& operator<<(double f);
56basic_ostream& operator<<(long double f);
57basic_ostream& operator<<(const void* p);
58basic_ostream& operator<<(const volatile void* val); // C++23
59basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
60basic_ostream& operator<<(nullptr_t);
61
62// 27.7.2.7 Unformatted output:
63basic_ostream& put(char_type c);
64basic_ostream& write(const char_type* s, streamsize n);
65basic_ostream& flush();
66
67// 27.7.2.5 seeks:
68pos_type tellp();
69basic_ostream& seekp(pos_type);
70basic_ostream& seekp(off_type, ios_base::seekdir);
71protected:
72basic_ostream(const basic_ostream& rhs) = delete;
73basic_ostream(basic_ostream&& rhs);
74// 27.7.3.3 Assign/swap
75basic_ostream& operator=(basic_ostream& rhs) = delete;
76basic_ostream& operator=(const basic_ostream&& rhs);
77void swap(basic_ostream& rhs);
78};
79
80// 27.7.2.6.4 character inserters
81
82template<class charT, class traits>
83basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT);
84
85template<class charT, class traits>
86basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char);
87
88template<class traits>
89basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char);
90
91// signed and unsigned
92
93template<class traits>
94basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char);
95
96template<class traits>
97basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char);
98
99// NTBS
100template<class charT, class traits>
101basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
102
103template<class charT, class traits>
104basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*);
105
106template<class traits>
107basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*);
108
109// signed and unsigned
110template<class traits>
111basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*);
112
113template<class traits>
114basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*);
115
116// swap:
117template <class charT, class traits>
118void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y);
119
120template <class charT, class traits>
121basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
122
123template <class charT, class traits>
124basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
125
126template <class charT, class traits>
127basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
128
129// rvalue stream insertion
130template <class Stream, class T>
131Stream&& operator<<(Stream&& os, const T& x);
132
133template<class traits>
134basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete; // since C++20
135template<class traits>
136basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete; // since C++20
137template<class traits>
138basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete; // since C++20
139template<class traits>
140basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete; // since C++20
141template<class traits>
142basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete; // since C++20
143template<class traits>
144basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete; // since C++20
145template<class traits>
146basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete; // since C++20
147template<class traits>
148basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete; // since C++20
149template<class traits>
150basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char8_t*) = delete; // since C++20
151template<class traits>
152basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char16_t*) = delete; // since C++20
153template<class traits>
154basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char32_t*) = delete; // since C++20
155template<class traits>
156basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete; // since C++20
157template<class traits>
158basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; // since C++20
159template<class traits>
160basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete; // since C++20
161
162// [ostream.formatted.print], print functions
163template<class... Args> // since C++23
164void print(ostream& os, format_string<Args...> fmt, Args&&... args);
165template<class... Args> // since C++23
166void println(ostream& os, format_string<Args...> fmt, Args&&... args);
167void println(ostream& os); // since C++26
168
169void vprint_unicode(ostream& os, string_view fmt, format_args args); // since C++23
170void vprint_nonunicode(ostream& os, string_view fmt, format_args args); // since C++23
171} // std
172
173*/
174
175#include <__config>
176#include <__ostream/basic_ostream.h>
177#include <__ostream/print.h>
178#include <version>
179
180#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
181# pragma GCC system_header
182#endif
183
184#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
185# include <atomic>
186# include <concepts>
187# include <cstdio>
188# include <cstdlib>
189# include <iosfwd>
190# include <iterator>
191# include <stdexcept>
192# include <type_traits>
193#endif
194
195#endif // _LIBCPP_OSTREAM
196