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