Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 791ef7b | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | 41d7aea | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_OSTREAM |
| 11 | #define _LIBCPP_OSTREAM |
| 12 | |
| 13 | /* |
| 14 | ostream synopsis |
| 15 | |
| 16 | template <class charT, class traits = char_traits<charT> > |
| 17 | class basic_ostream |
| 18 | : virtual public basic_ios<charT,traits> |
| 19 | { |
| 20 | public: |
| 21 | // types (inherited from basic_ios (27.5.4)): |
| 22 | typedef charT char_type; |
| 23 | typedef traits traits_type; |
| 24 | typedef typename traits_type::int_type int_type; |
| 25 | typedef typename traits_type::pos_type pos_type; |
| 26 | typedef typename traits_type::off_type off_type; |
| 27 | |
| 28 | // 27.7.2.2 Constructor/destructor: |
| 29 | explicit basic_ostream(basic_streambuf<char_type,traits>* sb); |
| 30 | basic_ostream(basic_ostream&& rhs); |
| 31 | virtual ~basic_ostream(); |
| 32 | |
| 33 | // 27.7.2.3 Assign/swap |
Marshall Clow | 21e7485 | 2013-08-14 15:15:28 +0000 | [diff] [blame] | 34 | basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14 |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 35 | basic_ostream& operator=(basic_ostream&& rhs); |
| 36 | void swap(basic_ostream& rhs); |
| 37 | |
| 38 | // 27.7.2.4 Prefix/suffix: |
| 39 | class sentry; |
| 40 | |
| 41 | // 27.7.2.6 Formatted output: |
| 42 | basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&)); |
| 43 | basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT,traits>&)); |
| 44 | basic_ostream& operator<<(ios_base& (*pf)(ios_base&)); |
| 45 | basic_ostream& operator<<(bool n); |
| 46 | basic_ostream& operator<<(short n); |
| 47 | basic_ostream& operator<<(unsigned short n); |
| 48 | basic_ostream& operator<<(int n); |
| 49 | basic_ostream& operator<<(unsigned int n); |
| 50 | basic_ostream& operator<<(long n); |
| 51 | basic_ostream& operator<<(unsigned long n); |
| 52 | basic_ostream& operator<<(long long n); |
| 53 | basic_ostream& operator<<(unsigned long long n); |
| 54 | basic_ostream& operator<<(float f); |
| 55 | basic_ostream& operator<<(double f); |
| 56 | basic_ostream& operator<<(long double f); |
| 57 | basic_ostream& operator<<(const void* p); |
Nikolas Klauser | 02c0f16 | 2021-11-09 11:41:46 -0500 | [diff] [blame] | 58 | basic_ostream& operator<<(const volatile void* val); // C++23 |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 59 | basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb); |
Marshall Clow | 27e2e6a | 2019-07-01 16:20:25 +0000 | [diff] [blame] | 60 | basic_ostream& operator<<(nullptr_t); |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 61 | |
| 62 | // 27.7.2.7 Unformatted output: |
| 63 | basic_ostream& put(char_type c); |
| 64 | basic_ostream& write(const char_type* s, streamsize n); |
| 65 | basic_ostream& flush(); |
| 66 | |
| 67 | // 27.7.2.5 seeks: |
| 68 | pos_type tellp(); |
| 69 | basic_ostream& seekp(pos_type); |
| 70 | basic_ostream& seekp(off_type, ios_base::seekdir); |
Marshall Clow | 1e0ab2e | 2014-09-16 15:27:01 +0000 | [diff] [blame] | 71 | protected: |
| 72 | basic_ostream(const basic_ostream& rhs) = delete; |
| 73 | basic_ostream(basic_ostream&& rhs); |
| 74 | // 27.7.3.3 Assign/swap |
| 75 | basic_ostream& operator=(basic_ostream& rhs) = delete; |
| 76 | basic_ostream& operator=(const basic_ostream&& rhs); |
| 77 | void swap(basic_ostream& rhs); |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | // 27.7.2.6.4 character inserters |
| 81 | |
| 82 | template<class charT, class traits> |
| 83 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT); |
| 84 | |
| 85 | template<class charT, class traits> |
| 86 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char); |
| 87 | |
| 88 | template<class traits> |
| 89 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char); |
| 90 | |
| 91 | // signed and unsigned |
| 92 | |
| 93 | template<class traits> |
| 94 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char); |
| 95 | |
| 96 | template<class traits> |
| 97 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char); |
| 98 | |
| 99 | // NTBS |
| 100 | template<class charT, class traits> |
| 101 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*); |
| 102 | |
| 103 | template<class charT, class traits> |
| 104 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*); |
| 105 | |
| 106 | template<class traits> |
| 107 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*); |
| 108 | |
| 109 | // signed and unsigned |
| 110 | template<class traits> |
| 111 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*); |
| 112 | |
| 113 | template<class traits> |
| 114 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*); |
| 115 | |
| 116 | // swap: |
| 117 | template <class charT, class traits> |
| 118 | void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y); |
| 119 | |
| 120 | template <class charT, class traits> |
| 121 | basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os); |
| 122 | |
| 123 | template <class charT, class traits> |
| 124 | basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os); |
| 125 | |
| 126 | template <class charT, class traits> |
| 127 | basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os); |
| 128 | |
| 129 | // rvalue stream insertion |
Louis Dionne | d83b3f1 | 2020-09-23 08:49:00 -0400 | [diff] [blame] | 130 | template <class Stream, class T> |
| 131 | Stream&& operator<<(Stream&& os, const T& x); |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 132 | |
Nikolas Klauser | d8d4ce5 | 2022-07-19 02:03:10 +0200 | [diff] [blame] | 133 | template<class traits> |
| 134 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete; // since C++20 |
| 135 | template<class traits> |
| 136 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete; // since C++20 |
| 137 | template<class traits> |
| 138 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete; // since C++20 |
| 139 | template<class traits> |
| 140 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete; // since C++20 |
| 141 | template<class traits> |
| 142 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete; // since C++20 |
| 143 | template<class traits> |
| 144 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete; // since C++20 |
| 145 | template<class traits> |
| 146 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete; // since C++20 |
| 147 | template<class traits> |
| 148 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete; // since C++20 |
| 149 | template<class traits> |
| 150 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char8_t*) = delete; // since C++20 |
| 151 | template<class traits> |
| 152 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char16_t*) = delete; // since C++20 |
| 153 | template<class traits> |
| 154 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char32_t*) = delete; // since C++20 |
| 155 | template<class traits> |
| 156 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete; // since C++20 |
| 157 | template<class traits> |
| 158 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; // since C++20 |
| 159 | template<class traits> |
| 160 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete; // since C++20 |
| 161 | |
Mark de Wever | 7993687 | 2023-12-19 19:32:17 +0100 | [diff] [blame] | 162 | // [ostream.formatted.print], print functions |
| 163 | template<class... Args> // since C++23 |
| 164 | void print(ostream& os, format_string<Args...> fmt, Args&&... args); |
| 165 | template<class... Args> // since C++23 |
| 166 | void println(ostream& os, format_string<Args...> fmt, Args&&... args); |
Hristo Hristov | e43499c | 2024-04-06 21:52:52 +0300 | [diff] [blame] | 167 | void println(ostream& os); // since C++26 |
Mark de Wever | 7993687 | 2023-12-19 19:32:17 +0100 | [diff] [blame] | 168 | |
| 169 | void vprint_unicode(ostream& os, string_view fmt, format_args args); // since C++23 |
| 170 | void vprint_nonunicode(ostream& os, string_view fmt, format_args args); // since C++23 |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 171 | } // std |
| 172 | |
| 173 | */ |
| 174 | |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 175 | #include <__config> |
Nikolas Klauser | 95483d7 | 2024-07-18 10:59:58 +0200 | [diff] [blame] | 176 | |
Nikolas Klauser | 9b2b38b | 2024-11-06 10:39:19 +0100 | [diff] [blame] | 177 | #if _LIBCPP_HAS_LOCALIZATION |
Nikolas Klauser | 95483d7 | 2024-07-18 10:59:58 +0200 | [diff] [blame] | 178 | |
Louis Dionne | 166e494 | 2024-09-16 08:15:38 -0400 | [diff] [blame] | 179 | # include <__ostream/basic_ostream.h> |
Nikolas Klauser | 95483d7 | 2024-07-18 10:59:58 +0200 | [diff] [blame] | 180 | |
Louis Dionne | 166e494 | 2024-09-16 08:15:38 -0400 | [diff] [blame] | 181 | # if _LIBCPP_STD_VER >= 23 |
| 182 | # include <__ostream/print.h> |
| 183 | # endif |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 184 | |
Louis Dionne | 166e494 | 2024-09-16 08:15:38 -0400 | [diff] [blame] | 185 | # include <version> |
| 186 | |
| 187 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 188 | # pragma GCC system_header |
| 189 | # endif |
| 190 | |
Nikolas Klauser | 9b2b38b | 2024-11-06 10:39:19 +0100 | [diff] [blame] | 191 | #endif // _LIBCPP_HAS_LOCALIZATION |
Howard Hinnant | ed395bf | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 192 | |
Mark de Wever | 7961c22 | 2022-09-02 17:53:28 +0200 | [diff] [blame] | 193 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
Nikolas Klauser | f83f5f3 | 2023-01-31 19:23:30 +0100 | [diff] [blame] | 194 | # include <atomic> |
Nikolas Klauser | 571b449 | 2022-09-22 21:53:13 +0200 | [diff] [blame] | 195 | # include <concepts> |
Nikolas Klauser | 3b5a2ea | 2024-05-02 22:38:44 +0200 | [diff] [blame] | 196 | # include <cstdio> |
Nikolas Klauser | 1503ae6 | 2023-01-08 16:47:53 +0100 | [diff] [blame] | 197 | # include <cstdlib> |
Nikolas Klauser | 95483d7 | 2024-07-18 10:59:58 +0200 | [diff] [blame] | 198 | # include <format> |
philnik777 | cf4fd93 | 2023-10-29 18:31:37 +0100 | [diff] [blame] | 199 | # include <iosfwd> |
Mark de Wever | 7961c22 | 2022-09-02 17:53:28 +0200 | [diff] [blame] | 200 | # include <iterator> |
Nikolas Klauser | 95483d7 | 2024-07-18 10:59:58 +0200 | [diff] [blame] | 201 | # include <print> |
philnik777 | cf4fd93 | 2023-10-29 18:31:37 +0100 | [diff] [blame] | 202 | # include <stdexcept> |
Nikolas Klauser | 2aa253f | 2022-12-21 00:07:17 +0100 | [diff] [blame] | 203 | # include <type_traits> |
Mark de Wever | 7961c22 | 2022-09-02 17:53:28 +0200 | [diff] [blame] | 204 | #endif |
| 205 | |
Louis Dionne | 8460cc4 | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 206 | #endif // _LIBCPP_OSTREAM |