Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- ostream -----------------------------------===// |
| 3 | // |
Chandler Carruth | d201210 | 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 | c51e102 | 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 | e9ca027 | 2013-08-14 15:15:28 +0000 | [diff] [blame] | 34 | basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14 |
Howard Hinnant | c51e102 | 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); |
| 58 | basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb); |
Marshall Clow | 706862d | 2019-07-01 16:20:25 +0000 | [diff] [blame] | 59 | basic_ostream& operator<<(nullptr_t); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 | |
| 61 | // 27.7.2.7 Unformatted output: |
| 62 | basic_ostream& put(char_type c); |
| 63 | basic_ostream& write(const char_type* s, streamsize n); |
| 64 | basic_ostream& flush(); |
| 65 | |
| 66 | // 27.7.2.5 seeks: |
| 67 | pos_type tellp(); |
| 68 | basic_ostream& seekp(pos_type); |
| 69 | basic_ostream& seekp(off_type, ios_base::seekdir); |
Marshall Clow | 27d2987 | 2014-09-16 15:27:01 +0000 | [diff] [blame] | 70 | protected: |
| 71 | basic_ostream(const basic_ostream& rhs) = delete; |
| 72 | basic_ostream(basic_ostream&& rhs); |
| 73 | // 27.7.3.3 Assign/swap |
| 74 | basic_ostream& operator=(basic_ostream& rhs) = delete; |
| 75 | basic_ostream& operator=(const basic_ostream&& rhs); |
| 76 | void swap(basic_ostream& rhs); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | // 27.7.2.6.4 character inserters |
| 80 | |
| 81 | template<class charT, class traits> |
| 82 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT); |
| 83 | |
| 84 | template<class charT, class traits> |
| 85 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char); |
| 86 | |
| 87 | template<class traits> |
| 88 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char); |
| 89 | |
| 90 | // signed and unsigned |
| 91 | |
| 92 | template<class traits> |
| 93 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char); |
| 94 | |
| 95 | template<class traits> |
| 96 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char); |
| 97 | |
| 98 | // NTBS |
| 99 | template<class charT, class traits> |
| 100 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*); |
| 101 | |
| 102 | template<class charT, class traits> |
| 103 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*); |
| 104 | |
| 105 | template<class traits> |
| 106 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*); |
| 107 | |
| 108 | // signed and unsigned |
| 109 | template<class traits> |
| 110 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*); |
| 111 | |
| 112 | template<class traits> |
| 113 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*); |
| 114 | |
| 115 | // swap: |
| 116 | template <class charT, class traits> |
| 117 | void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y); |
| 118 | |
| 119 | template <class charT, class traits> |
| 120 | basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os); |
| 121 | |
| 122 | template <class charT, class traits> |
| 123 | basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os); |
| 124 | |
| 125 | template <class charT, class traits> |
| 126 | basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os); |
| 127 | |
| 128 | // rvalue stream insertion |
Louis Dionne | d9f73b1 | 2020-09-23 08:49:00 -0400 | [diff] [blame] | 129 | template <class Stream, class T> |
| 130 | Stream&& operator<<(Stream&& os, const T& x); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 131 | |
| 132 | } // std |
| 133 | |
| 134 | */ |
| 135 | |
| 136 | #include <__config> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 137 | #include <bitset> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 138 | #include <ios> |
| 139 | #include <iterator> |
| 140 | #include <locale> |
| 141 | #include <streambuf> |
Marshall Clow | 8732fed | 2018-12-11 04:35:44 +0000 | [diff] [blame] | 142 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 143 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 144 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 145 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 146 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 147 | |
| 148 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 149 | |
| 150 | template <class _CharT, class _Traits> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 151 | class _LIBCPP_TEMPLATE_VIS basic_ostream |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 152 | : virtual public basic_ios<_CharT, _Traits> |
| 153 | { |
| 154 | public: |
| 155 | // types (inherited from basic_ios (27.5.4)): |
| 156 | typedef _CharT char_type; |
| 157 | typedef _Traits traits_type; |
| 158 | typedef typename traits_type::int_type int_type; |
| 159 | typedef typename traits_type::pos_type pos_type; |
| 160 | typedef typename traits_type::off_type off_type; |
| 161 | |
| 162 | // 27.7.2.2 Constructor/destructor: |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 163 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 164 | explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb) |
| 165 | { this->init(__sb); } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 166 | virtual ~basic_ostream(); |
| 167 | protected: |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 168 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 169 | basic_ostream(basic_ostream&& __rhs); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 170 | |
| 171 | // 27.7.2.3 Assign/swap |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 172 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 173 | basic_ostream& operator=(basic_ostream&& __rhs); |
Arthur O'Dwyer | 8dcd298 | 2021-06-15 12:47:05 -0400 | [diff] [blame] | 174 | |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 175 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 176 | void swap(basic_ostream& __rhs) |
| 177 | { basic_ios<char_type, traits_type>::swap(__rhs); } |
Marshall Clow | 27d2987 | 2014-09-16 15:27:01 +0000 | [diff] [blame] | 178 | |
Marshall Clow | 242d9c1 | 2014-09-16 15:33:53 +0000 | [diff] [blame] | 179 | basic_ostream (const basic_ostream& __rhs) = delete; |
| 180 | basic_ostream& operator=(const basic_ostream& __rhs) = delete; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 181 | |
Arthur O'Dwyer | 8dcd298 | 2021-06-15 12:47:05 -0400 | [diff] [blame] | 182 | public: |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 183 | // 27.7.2.4 Prefix/suffix: |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 184 | class _LIBCPP_TEMPLATE_VIS sentry; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 185 | |
| 186 | // 27.7.2.6 Formatted output: |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 187 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 188 | basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) |
| 189 | { return __pf(*this); } |
| 190 | |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 191 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 192 | basic_ostream& operator<<(basic_ios<char_type, traits_type>& |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 193 | (*__pf)(basic_ios<char_type,traits_type>&)) |
| 194 | { __pf(*this); return *this; } |
| 195 | |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 196 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 197 | basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) |
| 198 | { __pf(*this); return *this; } |
| 199 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 200 | basic_ostream& operator<<(bool __n); |
| 201 | basic_ostream& operator<<(short __n); |
| 202 | basic_ostream& operator<<(unsigned short __n); |
| 203 | basic_ostream& operator<<(int __n); |
| 204 | basic_ostream& operator<<(unsigned int __n); |
| 205 | basic_ostream& operator<<(long __n); |
| 206 | basic_ostream& operator<<(unsigned long __n); |
| 207 | basic_ostream& operator<<(long long __n); |
| 208 | basic_ostream& operator<<(unsigned long long __n); |
| 209 | basic_ostream& operator<<(float __f); |
| 210 | basic_ostream& operator<<(double __f); |
| 211 | basic_ostream& operator<<(long double __f); |
| 212 | basic_ostream& operator<<(const void* __p); |
| 213 | basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); |
| 214 | |
Marshall Clow | 706862d | 2019-07-01 16:20:25 +0000 | [diff] [blame] | 215 | _LIBCPP_INLINE_VISIBILITY |
| 216 | basic_ostream& operator<<(nullptr_t) |
| 217 | { return *this << "nullptr"; } |
| 218 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 219 | // 27.7.2.7 Unformatted output: |
| 220 | basic_ostream& put(char_type __c); |
| 221 | basic_ostream& write(const char_type* __s, streamsize __n); |
| 222 | basic_ostream& flush(); |
| 223 | |
| 224 | // 27.7.2.5 seeks: |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 225 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 226 | pos_type tellp(); |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 227 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 228 | basic_ostream& seekp(pos_type __pos); |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 229 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 230 | basic_ostream& seekp(off_type __off, ios_base::seekdir __dir); |
| 231 | |
| 232 | protected: |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 233 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 234 | basic_ostream() {} // extension, intentially does not initialize |
| 235 | }; |
| 236 | |
| 237 | template <class _CharT, class _Traits> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 238 | class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 239 | { |
| 240 | bool __ok_; |
| 241 | basic_ostream<_CharT, _Traits>& __os_; |
| 242 | |
| 243 | sentry(const sentry&); // = delete; |
| 244 | sentry& operator=(const sentry&); // = delete; |
| 245 | |
| 246 | public: |
| 247 | explicit sentry(basic_ostream<_CharT, _Traits>& __os); |
| 248 | ~sentry(); |
| 249 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 250 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 6c9c9a7 | 2021-06-15 12:57:54 -0400 | [diff] [blame] | 251 | explicit operator bool() const {return __ok_;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 252 | }; |
| 253 | |
| 254 | template <class _CharT, class _Traits> |
| 255 | basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os) |
| 256 | : __ok_(false), |
| 257 | __os_(__os) |
| 258 | { |
| 259 | if (__os.good()) |
| 260 | { |
| 261 | if (__os.tie()) |
| 262 | __os.tie()->flush(); |
| 263 | __ok_ = true; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | template <class _CharT, class _Traits> |
| 268 | basic_ostream<_CharT, _Traits>::sentry::~sentry() |
| 269 | { |
| 270 | if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) |
| 271 | && !uncaught_exception()) |
| 272 | { |
| 273 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 274 | try |
| 275 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 276 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 277 | if (__os_.rdbuf()->pubsync() == -1) |
| 278 | __os_.setstate(ios_base::badbit); |
| 279 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 280 | } |
| 281 | catch (...) |
| 282 | { |
| 283 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 284 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 288 | template <class _CharT, class _Traits> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 289 | basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) |
| 290 | { |
| 291 | this->move(__rhs); |
| 292 | } |
| 293 | |
| 294 | template <class _CharT, class _Traits> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 295 | basic_ostream<_CharT, _Traits>& |
| 296 | basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) |
| 297 | { |
| 298 | swap(__rhs); |
| 299 | return *this; |
| 300 | } |
| 301 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 302 | template <class _CharT, class _Traits> |
| 303 | basic_ostream<_CharT, _Traits>::~basic_ostream() |
| 304 | { |
| 305 | } |
| 306 | |
| 307 | template <class _CharT, class _Traits> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 308 | basic_ostream<_CharT, _Traits>& |
| 309 | basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) |
| 310 | { |
| 311 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 312 | try |
| 313 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 314 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 315 | sentry __s(*this); |
| 316 | if (__s) |
| 317 | { |
| 318 | if (__sb) |
| 319 | { |
| 320 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 321 | try |
| 322 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 323 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 324 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
| 325 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; |
| 326 | _Ip __i(__sb); |
| 327 | _Ip __eof; |
| 328 | _Op __o(*this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 329 | size_t __c = 0; |
| 330 | for (; __i != __eof; ++__i, ++__o, ++__c) |
| 331 | { |
| 332 | *__o = *__i; |
| 333 | if (__o.failed()) |
| 334 | break; |
| 335 | } |
| 336 | if (__c == 0) |
| 337 | this->setstate(ios_base::failbit); |
| 338 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 339 | } |
| 340 | catch (...) |
| 341 | { |
| 342 | this->__set_failbit_and_consider_rethrow(); |
| 343 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 344 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 345 | } |
| 346 | else |
| 347 | this->setstate(ios_base::badbit); |
| 348 | } |
| 349 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 350 | } |
| 351 | catch (...) |
| 352 | { |
| 353 | this->__set_badbit_and_consider_rethrow(); |
| 354 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 355 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 356 | return *this; |
| 357 | } |
| 358 | |
| 359 | template <class _CharT, class _Traits> |
| 360 | basic_ostream<_CharT, _Traits>& |
| 361 | basic_ostream<_CharT, _Traits>::operator<<(bool __n) |
| 362 | { |
| 363 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 364 | try |
| 365 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 366 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 367 | sentry __s(*this); |
| 368 | if (__s) |
| 369 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 370 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 371 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 372 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 373 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 374 | } |
| 375 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 376 | } |
| 377 | catch (...) |
| 378 | { |
| 379 | this->__set_badbit_and_consider_rethrow(); |
| 380 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 381 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 382 | return *this; |
| 383 | } |
| 384 | |
| 385 | template <class _CharT, class _Traits> |
| 386 | basic_ostream<_CharT, _Traits>& |
| 387 | basic_ostream<_CharT, _Traits>::operator<<(short __n) |
| 388 | { |
| 389 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 390 | try |
| 391 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 392 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 393 | sentry __s(*this); |
| 394 | if (__s) |
| 395 | { |
| 396 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 397 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 398 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 399 | if (__f.put(*this, *this, this->fill(), |
| 400 | __flags == ios_base::oct || __flags == ios_base::hex ? |
| 401 | static_cast<long>(static_cast<unsigned short>(__n)) : |
| 402 | static_cast<long>(__n)).failed()) |
| 403 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 404 | } |
| 405 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 406 | } |
| 407 | catch (...) |
| 408 | { |
| 409 | this->__set_badbit_and_consider_rethrow(); |
| 410 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 411 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 412 | return *this; |
| 413 | } |
| 414 | |
| 415 | template <class _CharT, class _Traits> |
| 416 | basic_ostream<_CharT, _Traits>& |
| 417 | basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) |
| 418 | { |
| 419 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 420 | try |
| 421 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 422 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 423 | sentry __s(*this); |
| 424 | if (__s) |
| 425 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 426 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 427 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 428 | if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) |
| 429 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 430 | } |
| 431 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 432 | } |
| 433 | catch (...) |
| 434 | { |
| 435 | this->__set_badbit_and_consider_rethrow(); |
| 436 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 437 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 438 | return *this; |
| 439 | } |
| 440 | |
| 441 | template <class _CharT, class _Traits> |
| 442 | basic_ostream<_CharT, _Traits>& |
| 443 | basic_ostream<_CharT, _Traits>::operator<<(int __n) |
| 444 | { |
| 445 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 446 | try |
| 447 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 448 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 449 | sentry __s(*this); |
| 450 | if (__s) |
| 451 | { |
| 452 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 453 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 454 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 455 | if (__f.put(*this, *this, this->fill(), |
| 456 | __flags == ios_base::oct || __flags == ios_base::hex ? |
| 457 | static_cast<long>(static_cast<unsigned int>(__n)) : |
| 458 | static_cast<long>(__n)).failed()) |
| 459 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 460 | } |
| 461 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 462 | } |
| 463 | catch (...) |
| 464 | { |
| 465 | this->__set_badbit_and_consider_rethrow(); |
| 466 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 467 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 468 | return *this; |
| 469 | } |
| 470 | |
| 471 | template <class _CharT, class _Traits> |
| 472 | basic_ostream<_CharT, _Traits>& |
| 473 | basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) |
| 474 | { |
| 475 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 476 | try |
| 477 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 478 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 479 | sentry __s(*this); |
| 480 | if (__s) |
| 481 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 482 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 483 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 484 | if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) |
| 485 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 486 | } |
| 487 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 488 | } |
| 489 | catch (...) |
| 490 | { |
| 491 | this->__set_badbit_and_consider_rethrow(); |
| 492 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 493 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 494 | return *this; |
| 495 | } |
| 496 | |
| 497 | template <class _CharT, class _Traits> |
| 498 | basic_ostream<_CharT, _Traits>& |
| 499 | basic_ostream<_CharT, _Traits>::operator<<(long __n) |
| 500 | { |
| 501 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 502 | try |
| 503 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 504 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 505 | sentry __s(*this); |
| 506 | if (__s) |
| 507 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 508 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 509 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 510 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 511 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 512 | } |
| 513 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 514 | } |
| 515 | catch (...) |
| 516 | { |
| 517 | this->__set_badbit_and_consider_rethrow(); |
| 518 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 519 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 520 | return *this; |
| 521 | } |
| 522 | |
| 523 | template <class _CharT, class _Traits> |
| 524 | basic_ostream<_CharT, _Traits>& |
| 525 | basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) |
| 526 | { |
| 527 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 528 | try |
| 529 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 530 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 531 | sentry __s(*this); |
| 532 | if (__s) |
| 533 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 534 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 535 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 536 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 537 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 538 | } |
| 539 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 540 | } |
| 541 | catch (...) |
| 542 | { |
| 543 | this->__set_badbit_and_consider_rethrow(); |
| 544 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 545 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 546 | return *this; |
| 547 | } |
| 548 | |
| 549 | template <class _CharT, class _Traits> |
| 550 | basic_ostream<_CharT, _Traits>& |
| 551 | basic_ostream<_CharT, _Traits>::operator<<(long long __n) |
| 552 | { |
| 553 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 554 | try |
| 555 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 556 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 557 | sentry __s(*this); |
| 558 | if (__s) |
| 559 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 560 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 561 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 562 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 563 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 564 | } |
| 565 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 566 | } |
| 567 | catch (...) |
| 568 | { |
| 569 | this->__set_badbit_and_consider_rethrow(); |
| 570 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 571 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 572 | return *this; |
| 573 | } |
| 574 | |
| 575 | template <class _CharT, class _Traits> |
| 576 | basic_ostream<_CharT, _Traits>& |
| 577 | basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) |
| 578 | { |
| 579 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 580 | try |
| 581 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 582 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 583 | sentry __s(*this); |
| 584 | if (__s) |
| 585 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 586 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 587 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 588 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 589 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 590 | } |
| 591 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 592 | } |
| 593 | catch (...) |
| 594 | { |
| 595 | this->__set_badbit_and_consider_rethrow(); |
| 596 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 597 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 598 | return *this; |
| 599 | } |
| 600 | |
| 601 | template <class _CharT, class _Traits> |
| 602 | basic_ostream<_CharT, _Traits>& |
| 603 | basic_ostream<_CharT, _Traits>::operator<<(float __n) |
| 604 | { |
| 605 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 606 | try |
| 607 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 608 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 609 | sentry __s(*this); |
| 610 | if (__s) |
| 611 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 612 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 613 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 614 | if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed()) |
| 615 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 616 | } |
| 617 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 618 | } |
| 619 | catch (...) |
| 620 | { |
| 621 | this->__set_badbit_and_consider_rethrow(); |
| 622 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 623 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 624 | return *this; |
| 625 | } |
| 626 | |
| 627 | template <class _CharT, class _Traits> |
| 628 | basic_ostream<_CharT, _Traits>& |
| 629 | basic_ostream<_CharT, _Traits>::operator<<(double __n) |
| 630 | { |
| 631 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 632 | try |
| 633 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 634 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 635 | sentry __s(*this); |
| 636 | if (__s) |
| 637 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 638 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 639 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 640 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 641 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 642 | } |
| 643 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 644 | } |
| 645 | catch (...) |
| 646 | { |
| 647 | this->__set_badbit_and_consider_rethrow(); |
| 648 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 649 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 650 | return *this; |
| 651 | } |
| 652 | |
| 653 | template <class _CharT, class _Traits> |
| 654 | basic_ostream<_CharT, _Traits>& |
| 655 | basic_ostream<_CharT, _Traits>::operator<<(long double __n) |
| 656 | { |
| 657 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 658 | try |
| 659 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 660 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 661 | sentry __s(*this); |
| 662 | if (__s) |
| 663 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 664 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 665 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 666 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 667 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 668 | } |
| 669 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 670 | } |
| 671 | catch (...) |
| 672 | { |
| 673 | this->__set_badbit_and_consider_rethrow(); |
| 674 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 675 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 676 | return *this; |
| 677 | } |
| 678 | |
| 679 | template <class _CharT, class _Traits> |
| 680 | basic_ostream<_CharT, _Traits>& |
| 681 | basic_ostream<_CharT, _Traits>::operator<<(const void* __n) |
| 682 | { |
| 683 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 684 | try |
| 685 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 686 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 687 | sentry __s(*this); |
| 688 | if (__s) |
| 689 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 690 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; |
| 691 | const _Fp& __f = use_facet<_Fp>(this->getloc()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 692 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 693 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 694 | } |
| 695 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 696 | } |
| 697 | catch (...) |
| 698 | { |
| 699 | this->__set_badbit_and_consider_rethrow(); |
| 700 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 701 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 702 | return *this; |
| 703 | } |
| 704 | |
| 705 | template<class _CharT, class _Traits> |
| 706 | basic_ostream<_CharT, _Traits>& |
Marshall Clow | 0099564 | 2013-12-10 19:25:49 +0000 | [diff] [blame] | 707 | __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, |
| 708 | const _CharT* __str, size_t __len) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 709 | { |
| 710 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 711 | try |
| 712 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 713 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 714 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 715 | if (__s) |
| 716 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 717 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; |
| 718 | if (__pad_and_output(_Ip(__os), |
Marshall Clow | 0099564 | 2013-12-10 19:25:49 +0000 | [diff] [blame] | 719 | __str, |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 720 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
Marshall Clow | 0099564 | 2013-12-10 19:25:49 +0000 | [diff] [blame] | 721 | __str + __len : |
| 722 | __str, |
| 723 | __str + __len, |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 724 | __os, |
| 725 | __os.fill()).failed()) |
| 726 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 727 | } |
| 728 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 729 | } |
| 730 | catch (...) |
| 731 | { |
| 732 | __os.__set_badbit_and_consider_rethrow(); |
| 733 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 734 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 735 | return __os; |
| 736 | } |
| 737 | |
Volodymyr Sapsai | 4c14a92 | 2018-09-19 23:31:34 +0000 | [diff] [blame] | 738 | |
Marshall Clow | 0099564 | 2013-12-10 19:25:49 +0000 | [diff] [blame] | 739 | template<class _CharT, class _Traits> |
| 740 | basic_ostream<_CharT, _Traits>& |
| 741 | operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) |
| 742 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 743 | return _VSTD::__put_character_sequence(__os, &__c, 1); |
Marshall Clow | 0099564 | 2013-12-10 19:25:49 +0000 | [diff] [blame] | 744 | } |
| 745 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 746 | template<class _CharT, class _Traits> |
| 747 | basic_ostream<_CharT, _Traits>& |
| 748 | operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) |
| 749 | { |
| 750 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 751 | try |
| 752 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 753 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 754 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 755 | if (__s) |
| 756 | { |
| 757 | _CharT __c = __os.widen(__cn); |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 758 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; |
| 759 | if (__pad_and_output(_Ip(__os), |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 760 | &__c, |
| 761 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 762 | &__c + 1 : |
| 763 | &__c, |
| 764 | &__c + 1, |
| 765 | __os, |
| 766 | __os.fill()).failed()) |
| 767 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 768 | } |
| 769 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 770 | } |
| 771 | catch (...) |
| 772 | { |
| 773 | __os.__set_badbit_and_consider_rethrow(); |
| 774 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 775 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 776 | return __os; |
| 777 | } |
| 778 | |
| 779 | template<class _Traits> |
| 780 | basic_ostream<char, _Traits>& |
| 781 | operator<<(basic_ostream<char, _Traits>& __os, char __c) |
| 782 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 783 | return _VSTD::__put_character_sequence(__os, &__c, 1); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | template<class _Traits> |
| 787 | basic_ostream<char, _Traits>& |
| 788 | operator<<(basic_ostream<char, _Traits>& __os, signed char __c) |
| 789 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 790 | return _VSTD::__put_character_sequence(__os, (char *) &__c, 1); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | template<class _Traits> |
| 794 | basic_ostream<char, _Traits>& |
| 795 | operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) |
| 796 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 797 | return _VSTD::__put_character_sequence(__os, (char *) &__c, 1); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | template<class _CharT, class _Traits> |
| 801 | basic_ostream<_CharT, _Traits>& |
| 802 | operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) |
| 803 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 804 | return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | template<class _CharT, class _Traits> |
| 808 | basic_ostream<_CharT, _Traits>& |
| 809 | operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) |
| 810 | { |
| 811 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 812 | try |
| 813 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 814 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 815 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 816 | if (__s) |
| 817 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 818 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 819 | size_t __len = char_traits<char>::length(__strn); |
| 820 | const int __bs = 100; |
| 821 | _CharT __wbb[__bs]; |
| 822 | _CharT* __wb = __wbb; |
| 823 | unique_ptr<_CharT, void(*)(void*)> __h(0, free); |
| 824 | if (__len > __bs) |
| 825 | { |
| 826 | __wb = (_CharT*)malloc(__len*sizeof(_CharT)); |
| 827 | if (__wb == 0) |
| 828 | __throw_bad_alloc(); |
| 829 | __h.reset(__wb); |
| 830 | } |
| 831 | for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p) |
| 832 | *__p = __os.widen(*__strn); |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 833 | if (__pad_and_output(_Ip(__os), |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 834 | __wb, |
| 835 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 836 | __wb + __len : |
| 837 | __wb, |
| 838 | __wb + __len, |
| 839 | __os, |
| 840 | __os.fill()).failed()) |
| 841 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 842 | } |
| 843 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 844 | } |
| 845 | catch (...) |
| 846 | { |
| 847 | __os.__set_badbit_and_consider_rethrow(); |
| 848 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 849 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 850 | return __os; |
| 851 | } |
| 852 | |
| 853 | template<class _Traits> |
| 854 | basic_ostream<char, _Traits>& |
| 855 | operator<<(basic_ostream<char, _Traits>& __os, const char* __str) |
| 856 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 857 | return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | template<class _Traits> |
| 861 | basic_ostream<char, _Traits>& |
| 862 | operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str) |
| 863 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 864 | const char *__s = (const char *) __str; |
| 865 | return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 866 | } |
| 867 | |
| 868 | template<class _Traits> |
| 869 | basic_ostream<char, _Traits>& |
| 870 | operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) |
| 871 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 872 | const char *__s = (const char *) __str; |
| 873 | return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | template <class _CharT, class _Traits> |
| 877 | basic_ostream<_CharT, _Traits>& |
| 878 | basic_ostream<_CharT, _Traits>::put(char_type __c) |
| 879 | { |
| 880 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 881 | try |
| 882 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 883 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 884 | sentry __s(*this); |
| 885 | if (__s) |
| 886 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 887 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; |
| 888 | _Op __o(*this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 889 | *__o = __c; |
| 890 | if (__o.failed()) |
| 891 | this->setstate(ios_base::badbit); |
| 892 | } |
| 893 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 894 | } |
| 895 | catch (...) |
| 896 | { |
| 897 | this->__set_badbit_and_consider_rethrow(); |
| 898 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 899 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 900 | return *this; |
| 901 | } |
| 902 | |
| 903 | template <class _CharT, class _Traits> |
| 904 | basic_ostream<_CharT, _Traits>& |
| 905 | basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) |
| 906 | { |
| 907 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 908 | try |
| 909 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 910 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 911 | sentry __sen(*this); |
| 912 | if (__sen && __n) |
| 913 | { |
Howard Hinnant | 79cef93 | 2013-01-15 17:22:03 +0000 | [diff] [blame] | 914 | if (this->rdbuf()->sputn(__s, __n) != __n) |
| 915 | this->setstate(ios_base::badbit); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 916 | } |
| 917 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 918 | } |
| 919 | catch (...) |
| 920 | { |
| 921 | this->__set_badbit_and_consider_rethrow(); |
| 922 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 923 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 924 | return *this; |
| 925 | } |
| 926 | |
| 927 | template <class _CharT, class _Traits> |
| 928 | basic_ostream<_CharT, _Traits>& |
| 929 | basic_ostream<_CharT, _Traits>::flush() |
| 930 | { |
| 931 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 932 | try |
| 933 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 934 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 935 | if (this->rdbuf()) |
| 936 | { |
| 937 | sentry __s(*this); |
| 938 | if (__s) |
| 939 | { |
| 940 | if (this->rdbuf()->pubsync() == -1) |
| 941 | this->setstate(ios_base::badbit); |
| 942 | } |
| 943 | } |
| 944 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 945 | } |
| 946 | catch (...) |
| 947 | { |
| 948 | this->__set_badbit_and_consider_rethrow(); |
| 949 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 950 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 951 | return *this; |
| 952 | } |
| 953 | |
| 954 | template <class _CharT, class _Traits> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 955 | typename basic_ostream<_CharT, _Traits>::pos_type |
| 956 | basic_ostream<_CharT, _Traits>::tellp() |
| 957 | { |
| 958 | if (this->fail()) |
| 959 | return pos_type(-1); |
| 960 | return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); |
| 961 | } |
| 962 | |
| 963 | template <class _CharT, class _Traits> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 964 | basic_ostream<_CharT, _Traits>& |
| 965 | basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) |
| 966 | { |
Marshall Clow | 29c4daa | 2013-10-31 22:20:45 +0000 | [diff] [blame] | 967 | sentry __s(*this); |
Marshall Clow | 8aa079a | 2015-06-22 15:01:21 +0000 | [diff] [blame] | 968 | if (!this->fail()) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 969 | { |
| 970 | if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) |
| 971 | this->setstate(ios_base::failbit); |
| 972 | } |
| 973 | return *this; |
| 974 | } |
| 975 | |
| 976 | template <class _CharT, class _Traits> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 977 | basic_ostream<_CharT, _Traits>& |
| 978 | basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) |
| 979 | { |
Marshall Clow | 29c4daa | 2013-10-31 22:20:45 +0000 | [diff] [blame] | 980 | sentry __s(*this); |
Marshall Clow | 8aa079a | 2015-06-22 15:01:21 +0000 | [diff] [blame] | 981 | if (!this->fail()) |
Marshall Clow | 29c4daa | 2013-10-31 22:20:45 +0000 | [diff] [blame] | 982 | { |
| 983 | if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1)) |
| 984 | this->setstate(ios_base::failbit); |
| 985 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 986 | return *this; |
| 987 | } |
| 988 | |
| 989 | template <class _CharT, class _Traits> |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 990 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 991 | basic_ostream<_CharT, _Traits>& |
| 992 | endl(basic_ostream<_CharT, _Traits>& __os) |
| 993 | { |
| 994 | __os.put(__os.widen('\n')); |
| 995 | __os.flush(); |
| 996 | return __os; |
| 997 | } |
| 998 | |
| 999 | template <class _CharT, class _Traits> |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 1000 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1001 | basic_ostream<_CharT, _Traits>& |
| 1002 | ends(basic_ostream<_CharT, _Traits>& __os) |
| 1003 | { |
| 1004 | __os.put(_CharT()); |
| 1005 | return __os; |
| 1006 | } |
| 1007 | |
| 1008 | template <class _CharT, class _Traits> |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 1009 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1010 | basic_ostream<_CharT, _Traits>& |
| 1011 | flush(basic_ostream<_CharT, _Traits>& __os) |
| 1012 | { |
| 1013 | __os.flush(); |
| 1014 | return __os; |
| 1015 | } |
| 1016 | |
Louis Dionne | d9f73b1 | 2020-09-23 08:49:00 -0400 | [diff] [blame] | 1017 | template <class _Stream, class _Tp, class = void> |
| 1018 | struct __is_ostreamable : false_type { }; |
| 1019 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1020 | template <class _Stream, class _Tp> |
Louis Dionne | d9f73b1 | 2020-09-23 08:49:00 -0400 | [diff] [blame] | 1021 | struct __is_ostreamable<_Stream, _Tp, decltype( |
Arthur O'Dwyer | 3285c34 | 2021-05-10 13:04:16 -0400 | [diff] [blame] | 1022 | declval<_Stream>() << declval<_Tp>(), void() |
Louis Dionne | d9f73b1 | 2020-09-23 08:49:00 -0400 | [diff] [blame] | 1023 | )> : true_type { }; |
| 1024 | |
| 1025 | template <class _Stream, class _Tp, class = typename enable_if< |
| 1026 | _And<is_base_of<ios_base, _Stream>, |
Arthur O'Dwyer | 46d358c | 2021-06-15 12:57:05 -0400 | [diff] [blame] | 1027 | __is_ostreamable<_Stream&, const _Tp&> >::value |
Louis Dionne | d9f73b1 | 2020-09-23 08:49:00 -0400 | [diff] [blame] | 1028 | >::type> |
| 1029 | _LIBCPP_INLINE_VISIBILITY |
| 1030 | _Stream&& operator<<(_Stream&& __os, const _Tp& __x) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1031 | { |
| 1032 | __os << __x; |
Howard Hinnant | c8697b6 | 2012-01-12 23:37:51 +0000 | [diff] [blame] | 1033 | return _VSTD::move(__os); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1034 | } |
| 1035 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1036 | template<class _CharT, class _Traits, class _Allocator> |
| 1037 | basic_ostream<_CharT, _Traits>& |
| 1038 | operator<<(basic_ostream<_CharT, _Traits>& __os, |
| 1039 | const basic_string<_CharT, _Traits, _Allocator>& __str) |
| 1040 | { |
Marshall Clow | 4bc2be2 | 2014-02-16 01:57:26 +0000 | [diff] [blame] | 1041 | return _VSTD::__put_character_sequence(__os, __str.data(), __str.size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1042 | } |
| 1043 | |
Marshall Clow | df63a6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 1044 | template<class _CharT, class _Traits> |
| 1045 | basic_ostream<_CharT, _Traits>& |
| 1046 | operator<<(basic_ostream<_CharT, _Traits>& __os, |
Eric Fiselier | 1411692 | 2019-09-25 18:56:54 +0000 | [diff] [blame] | 1047 | basic_string_view<_CharT, _Traits> __sv) |
Marshall Clow | df63a6d | 2016-07-21 05:31:24 +0000 | [diff] [blame] | 1048 | { |
| 1049 | return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size()); |
| 1050 | } |
| 1051 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1052 | template <class _CharT, class _Traits> |
Evgeniy Stepanov | b925426 | 2016-01-08 19:21:02 +0000 | [diff] [blame] | 1053 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1054 | basic_ostream<_CharT, _Traits>& |
| 1055 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) |
| 1056 | { |
| 1057 | return __os << __ec.category().name() << ':' << __ec.value(); |
| 1058 | } |
| 1059 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1060 | template<class _CharT, class _Traits, class _Yp> |
Evgeniy Stepanov | b925426 | 2016-01-08 19:21:02 +0000 | [diff] [blame] | 1061 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1062 | basic_ostream<_CharT, _Traits>& |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1063 | operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1064 | { |
| 1065 | return __os << __p.get(); |
| 1066 | } |
| 1067 | |
Marshall Clow | e52a324 | 2017-11-27 15:51:36 +0000 | [diff] [blame] | 1068 | template<class _CharT, class _Traits, class _Yp, class _Dp> |
| 1069 | inline _LIBCPP_INLINE_VISIBILITY |
| 1070 | typename enable_if |
| 1071 | < |
Marshall Clow | eea0a1d | 2018-03-22 18:27:28 +0000 | [diff] [blame] | 1072 | is_same<void, typename __void_t<decltype((declval<basic_ostream<_CharT, _Traits>&>() << declval<typename unique_ptr<_Yp, _Dp>::pointer>()))>::type>::value, |
Marshall Clow | e52a324 | 2017-11-27 15:51:36 +0000 | [diff] [blame] | 1073 | basic_ostream<_CharT, _Traits>& |
| 1074 | >::type |
| 1075 | operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) |
| 1076 | { |
| 1077 | return __os << __p.get(); |
| 1078 | } |
| 1079 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1080 | template <class _CharT, class _Traits, size_t _Size> |
| 1081 | basic_ostream<_CharT, _Traits>& |
Howard Hinnant | fa65ab6 | 2011-04-05 14:55:28 +0000 | [diff] [blame] | 1082 | operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1083 | { |
| 1084 | return __os << __x.template to_string<_CharT, _Traits> |
| 1085 | (use_facet<ctype<_CharT> >(__os.getloc()).widen('0'), |
| 1086 | use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); |
| 1087 | } |
| 1088 | |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 1089 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>) |
| 1090 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1091 | |
| 1092 | _LIBCPP_END_NAMESPACE_STD |
| 1093 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1094 | #endif // _LIBCPP_OSTREAM |