Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- ostream -----------------------------------===// |
| 3 | // |
Howard Hinnant | c566dc3 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | ee11c31 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_OSTREAM |
| 12 | #define _LIBCPP_OSTREAM |
| 13 | |
| 14 | /* |
| 15 | ostream synopsis |
| 16 | |
| 17 | template <class charT, class traits = char_traits<charT> > |
| 18 | class basic_ostream |
| 19 | : virtual public basic_ios<charT,traits> |
| 20 | { |
| 21 | public: |
| 22 | // types (inherited from basic_ios (27.5.4)): |
| 23 | typedef charT char_type; |
| 24 | typedef traits traits_type; |
| 25 | typedef typename traits_type::int_type int_type; |
| 26 | typedef typename traits_type::pos_type pos_type; |
| 27 | typedef typename traits_type::off_type off_type; |
| 28 | |
| 29 | // 27.7.2.2 Constructor/destructor: |
| 30 | explicit basic_ostream(basic_streambuf<char_type,traits>* sb); |
| 31 | basic_ostream(basic_ostream&& rhs); |
| 32 | virtual ~basic_ostream(); |
| 33 | |
| 34 | // 27.7.2.3 Assign/swap |
| 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); |
| 59 | |
| 60 | // 27.7.2.7 Unformatted output: |
| 61 | basic_ostream& put(char_type c); |
| 62 | basic_ostream& write(const char_type* s, streamsize n); |
| 63 | basic_ostream& flush(); |
| 64 | |
| 65 | // 27.7.2.5 seeks: |
| 66 | pos_type tellp(); |
| 67 | basic_ostream& seekp(pos_type); |
| 68 | basic_ostream& seekp(off_type, ios_base::seekdir); |
| 69 | }; |
| 70 | |
| 71 | // 27.7.2.6.4 character inserters |
| 72 | |
| 73 | template<class charT, class traits> |
| 74 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT); |
| 75 | |
| 76 | template<class charT, class traits> |
| 77 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char); |
| 78 | |
| 79 | template<class traits> |
| 80 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char); |
| 81 | |
| 82 | // signed and unsigned |
| 83 | |
| 84 | template<class traits> |
| 85 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char); |
| 86 | |
| 87 | template<class traits> |
| 88 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char); |
| 89 | |
| 90 | // NTBS |
| 91 | template<class charT, class traits> |
| 92 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*); |
| 93 | |
| 94 | template<class charT, class traits> |
| 95 | basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*); |
| 96 | |
| 97 | template<class traits> |
| 98 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*); |
| 99 | |
| 100 | // signed and unsigned |
| 101 | template<class traits> |
| 102 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*); |
| 103 | |
| 104 | template<class traits> |
| 105 | basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*); |
| 106 | |
| 107 | // swap: |
| 108 | template <class charT, class traits> |
| 109 | void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y); |
| 110 | |
| 111 | template <class charT, class traits> |
| 112 | basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os); |
| 113 | |
| 114 | template <class charT, class traits> |
| 115 | basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os); |
| 116 | |
| 117 | template <class charT, class traits> |
| 118 | basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os); |
| 119 | |
| 120 | // rvalue stream insertion |
| 121 | template <class charT, class traits, class T> |
| 122 | basic_ostream<charT, traits>& |
| 123 | operator<<(basic_ostream<charT, traits>&& os, const T& x); |
| 124 | |
| 125 | } // std |
| 126 | |
| 127 | */ |
| 128 | |
| 129 | #include <__config> |
| 130 | #include <ios> |
| 131 | #include <streambuf> |
| 132 | #include <locale> |
| 133 | #include <iterator> |
| 134 | #include <bitset> |
| 135 | |
| 136 | #pragma GCC system_header |
| 137 | |
| 138 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 139 | |
| 140 | template <class _CharT, class _Traits> |
Howard Hinnant | f5f9999 | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 141 | class _LIBCPP_VISIBLE basic_ostream |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 142 | : virtual public basic_ios<_CharT, _Traits> |
| 143 | { |
| 144 | public: |
| 145 | // types (inherited from basic_ios (27.5.4)): |
| 146 | typedef _CharT char_type; |
| 147 | typedef _Traits traits_type; |
| 148 | typedef typename traits_type::int_type int_type; |
| 149 | typedef typename traits_type::pos_type pos_type; |
| 150 | typedef typename traits_type::off_type off_type; |
| 151 | |
| 152 | // 27.7.2.2 Constructor/destructor: |
| 153 | explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb); |
| 154 | virtual ~basic_ostream(); |
| 155 | protected: |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 156 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 0dcdf02 | 2011-07-07 21:03:52 +0000 | [diff] [blame^] | 157 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 158 | basic_ostream(basic_ostream&& __rhs); |
| 159 | #endif |
| 160 | |
| 161 | // 27.7.2.3 Assign/swap |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 162 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 0dcdf02 | 2011-07-07 21:03:52 +0000 | [diff] [blame^] | 163 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 164 | basic_ostream& operator=(basic_ostream&& __rhs); |
| 165 | #endif |
| 166 | void swap(basic_ostream& __rhs); |
| 167 | public: |
| 168 | |
| 169 | // 27.7.2.4 Prefix/suffix: |
| 170 | class sentry; |
| 171 | |
| 172 | // 27.7.2.6 Formatted output: |
| 173 | basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)); |
| 174 | basic_ostream& operator<<(basic_ios<char_type, traits_type>& |
| 175 | (*__pf)(basic_ios<char_type,traits_type>&)); |
| 176 | basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)); |
| 177 | basic_ostream& operator<<(bool __n); |
| 178 | basic_ostream& operator<<(short __n); |
| 179 | basic_ostream& operator<<(unsigned short __n); |
| 180 | basic_ostream& operator<<(int __n); |
| 181 | basic_ostream& operator<<(unsigned int __n); |
| 182 | basic_ostream& operator<<(long __n); |
| 183 | basic_ostream& operator<<(unsigned long __n); |
| 184 | basic_ostream& operator<<(long long __n); |
| 185 | basic_ostream& operator<<(unsigned long long __n); |
| 186 | basic_ostream& operator<<(float __f); |
| 187 | basic_ostream& operator<<(double __f); |
| 188 | basic_ostream& operator<<(long double __f); |
| 189 | basic_ostream& operator<<(const void* __p); |
| 190 | basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); |
| 191 | |
| 192 | // 27.7.2.7 Unformatted output: |
| 193 | basic_ostream& put(char_type __c); |
| 194 | basic_ostream& write(const char_type* __s, streamsize __n); |
| 195 | basic_ostream& flush(); |
| 196 | |
| 197 | // 27.7.2.5 seeks: |
| 198 | pos_type tellp(); |
| 199 | basic_ostream& seekp(pos_type __pos); |
| 200 | basic_ostream& seekp(off_type __off, ios_base::seekdir __dir); |
| 201 | |
| 202 | protected: |
| 203 | _LIBCPP_ALWAYS_INLINE |
| 204 | basic_ostream() {} // extension, intentially does not initialize |
| 205 | }; |
| 206 | |
| 207 | template <class _CharT, class _Traits> |
Howard Hinnant | f5f9999 | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 208 | class _LIBCPP_VISIBLE basic_ostream<_CharT, _Traits>::sentry |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 209 | { |
| 210 | bool __ok_; |
| 211 | basic_ostream<_CharT, _Traits>& __os_; |
| 212 | |
| 213 | sentry(const sentry&); // = delete; |
| 214 | sentry& operator=(const sentry&); // = delete; |
| 215 | |
| 216 | public: |
| 217 | explicit sentry(basic_ostream<_CharT, _Traits>& __os); |
| 218 | ~sentry(); |
| 219 | |
| 220 | _LIBCPP_ALWAYS_INLINE |
| 221 | // explicit |
| 222 | operator bool() const {return __ok_;} |
| 223 | }; |
| 224 | |
| 225 | template <class _CharT, class _Traits> |
| 226 | basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os) |
| 227 | : __ok_(false), |
| 228 | __os_(__os) |
| 229 | { |
| 230 | if (__os.good()) |
| 231 | { |
| 232 | if (__os.tie()) |
| 233 | __os.tie()->flush(); |
| 234 | __ok_ = true; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | template <class _CharT, class _Traits> |
| 239 | basic_ostream<_CharT, _Traits>::sentry::~sentry() |
| 240 | { |
| 241 | if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) |
| 242 | && !uncaught_exception()) |
| 243 | { |
| 244 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 245 | try |
| 246 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 247 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 248 | if (__os_.rdbuf()->pubsync() == -1) |
| 249 | __os_.setstate(ios_base::badbit); |
| 250 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 251 | } |
| 252 | catch (...) |
| 253 | { |
| 254 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 255 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
| 259 | template <class _CharT, class _Traits> |
| 260 | inline _LIBCPP_INLINE_VISIBILITY |
| 261 | basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf<char_type, traits_type>* __sb) |
| 262 | { |
| 263 | this->init(__sb); |
| 264 | } |
| 265 | |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 266 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 267 | |
| 268 | template <class _CharT, class _Traits> |
| 269 | inline _LIBCPP_INLINE_VISIBILITY |
| 270 | basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) |
| 271 | { |
| 272 | this->move(__rhs); |
| 273 | } |
| 274 | |
| 275 | template <class _CharT, class _Traits> |
| 276 | inline _LIBCPP_INLINE_VISIBILITY |
| 277 | basic_ostream<_CharT, _Traits>& |
| 278 | basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) |
| 279 | { |
| 280 | swap(__rhs); |
| 281 | return *this; |
| 282 | } |
| 283 | |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 284 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 285 | |
| 286 | template <class _CharT, class _Traits> |
| 287 | basic_ostream<_CharT, _Traits>::~basic_ostream() |
| 288 | { |
| 289 | } |
| 290 | |
| 291 | template <class _CharT, class _Traits> |
| 292 | inline _LIBCPP_INLINE_VISIBILITY |
| 293 | void |
| 294 | basic_ostream<_CharT, _Traits>::swap(basic_ostream& __rhs) |
| 295 | { |
| 296 | basic_ios<char_type, traits_type>::swap(__rhs); |
| 297 | } |
| 298 | |
| 299 | template <class _CharT, class _Traits> |
| 300 | inline _LIBCPP_INLINE_VISIBILITY |
| 301 | basic_ostream<_CharT, _Traits>& |
| 302 | basic_ostream<_CharT, _Traits>::operator<<(basic_ostream& (*__pf)(basic_ostream&)) |
| 303 | { |
| 304 | return __pf(*this); |
| 305 | } |
| 306 | |
| 307 | template <class _CharT, class _Traits> |
| 308 | inline _LIBCPP_INLINE_VISIBILITY |
| 309 | basic_ostream<_CharT, _Traits>& |
| 310 | basic_ostream<_CharT, _Traits>::operator<<(basic_ios<char_type, traits_type>& |
| 311 | (*__pf)(basic_ios<char_type,traits_type>&)) |
| 312 | { |
| 313 | __pf(*this); |
| 314 | return *this; |
| 315 | } |
| 316 | |
| 317 | template <class _CharT, class _Traits> |
| 318 | inline _LIBCPP_INLINE_VISIBILITY |
| 319 | basic_ostream<_CharT, _Traits>& |
| 320 | basic_ostream<_CharT, _Traits>::operator<<(ios_base& (*__pf)(ios_base&)) |
| 321 | { |
| 322 | __pf(*this); |
| 323 | return *this; |
| 324 | } |
| 325 | |
| 326 | template <class _CharT, class _Traits> |
| 327 | basic_ostream<_CharT, _Traits>& |
| 328 | basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) |
| 329 | { |
| 330 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 331 | try |
| 332 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 333 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 334 | sentry __s(*this); |
| 335 | if (__s) |
| 336 | { |
| 337 | if (__sb) |
| 338 | { |
| 339 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 340 | try |
| 341 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 342 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 343 | typedef istreambuf_iterator<_CharT, _Traits> _I; |
| 344 | typedef ostreambuf_iterator<_CharT, _Traits> _O; |
| 345 | _I __i(__sb); |
| 346 | _I __eof; |
| 347 | _O __o(*this); |
| 348 | size_t __c = 0; |
| 349 | for (; __i != __eof; ++__i, ++__o, ++__c) |
| 350 | { |
| 351 | *__o = *__i; |
| 352 | if (__o.failed()) |
| 353 | break; |
| 354 | } |
| 355 | if (__c == 0) |
| 356 | this->setstate(ios_base::failbit); |
| 357 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 358 | } |
| 359 | catch (...) |
| 360 | { |
| 361 | this->__set_failbit_and_consider_rethrow(); |
| 362 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 363 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 364 | } |
| 365 | else |
| 366 | this->setstate(ios_base::badbit); |
| 367 | } |
| 368 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 369 | } |
| 370 | catch (...) |
| 371 | { |
| 372 | this->__set_badbit_and_consider_rethrow(); |
| 373 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 374 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 375 | return *this; |
| 376 | } |
| 377 | |
| 378 | template <class _CharT, class _Traits> |
| 379 | basic_ostream<_CharT, _Traits>& |
| 380 | basic_ostream<_CharT, _Traits>::operator<<(bool __n) |
| 381 | { |
| 382 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 383 | try |
| 384 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 385 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 386 | sentry __s(*this); |
| 387 | if (__s) |
| 388 | { |
| 389 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 390 | const _F& __f = use_facet<_F>(this->getloc()); |
| 391 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 392 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 393 | } |
| 394 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 395 | } |
| 396 | catch (...) |
| 397 | { |
| 398 | this->__set_badbit_and_consider_rethrow(); |
| 399 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 400 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 401 | return *this; |
| 402 | } |
| 403 | |
| 404 | template <class _CharT, class _Traits> |
| 405 | basic_ostream<_CharT, _Traits>& |
| 406 | basic_ostream<_CharT, _Traits>::operator<<(short __n) |
| 407 | { |
| 408 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 409 | try |
| 410 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 411 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 412 | sentry __s(*this); |
| 413 | if (__s) |
| 414 | { |
| 415 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; |
| 416 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 417 | const _F& __f = use_facet<_F>(this->getloc()); |
| 418 | if (__f.put(*this, *this, this->fill(), |
| 419 | __flags == ios_base::oct || __flags == ios_base::hex ? |
| 420 | static_cast<long>(static_cast<unsigned short>(__n)) : |
| 421 | static_cast<long>(__n)).failed()) |
| 422 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 423 | } |
| 424 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 425 | } |
| 426 | catch (...) |
| 427 | { |
| 428 | this->__set_badbit_and_consider_rethrow(); |
| 429 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 430 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 431 | return *this; |
| 432 | } |
| 433 | |
| 434 | template <class _CharT, class _Traits> |
| 435 | basic_ostream<_CharT, _Traits>& |
| 436 | basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) |
| 437 | { |
| 438 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 439 | try |
| 440 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 441 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 442 | sentry __s(*this); |
| 443 | if (__s) |
| 444 | { |
| 445 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 446 | const _F& __f = use_facet<_F>(this->getloc()); |
| 447 | if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) |
| 448 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 449 | } |
| 450 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 451 | } |
| 452 | catch (...) |
| 453 | { |
| 454 | this->__set_badbit_and_consider_rethrow(); |
| 455 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 456 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 457 | return *this; |
| 458 | } |
| 459 | |
| 460 | template <class _CharT, class _Traits> |
| 461 | basic_ostream<_CharT, _Traits>& |
| 462 | basic_ostream<_CharT, _Traits>::operator<<(int __n) |
| 463 | { |
| 464 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 465 | try |
| 466 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 467 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 468 | sentry __s(*this); |
| 469 | if (__s) |
| 470 | { |
| 471 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; |
| 472 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 473 | const _F& __f = use_facet<_F>(this->getloc()); |
| 474 | if (__f.put(*this, *this, this->fill(), |
| 475 | __flags == ios_base::oct || __flags == ios_base::hex ? |
| 476 | static_cast<long>(static_cast<unsigned int>(__n)) : |
| 477 | static_cast<long>(__n)).failed()) |
| 478 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 479 | } |
| 480 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 481 | } |
| 482 | catch (...) |
| 483 | { |
| 484 | this->__set_badbit_and_consider_rethrow(); |
| 485 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 486 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 487 | return *this; |
| 488 | } |
| 489 | |
| 490 | template <class _CharT, class _Traits> |
| 491 | basic_ostream<_CharT, _Traits>& |
| 492 | basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) |
| 493 | { |
| 494 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 495 | try |
| 496 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 497 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 498 | sentry __s(*this); |
| 499 | if (__s) |
| 500 | { |
| 501 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 502 | const _F& __f = use_facet<_F>(this->getloc()); |
| 503 | if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) |
| 504 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 505 | } |
| 506 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 507 | } |
| 508 | catch (...) |
| 509 | { |
| 510 | this->__set_badbit_and_consider_rethrow(); |
| 511 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 512 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 513 | return *this; |
| 514 | } |
| 515 | |
| 516 | template <class _CharT, class _Traits> |
| 517 | basic_ostream<_CharT, _Traits>& |
| 518 | basic_ostream<_CharT, _Traits>::operator<<(long __n) |
| 519 | { |
| 520 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 521 | try |
| 522 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 523 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 524 | sentry __s(*this); |
| 525 | if (__s) |
| 526 | { |
| 527 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 528 | const _F& __f = use_facet<_F>(this->getloc()); |
| 529 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 530 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 531 | } |
| 532 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 533 | } |
| 534 | catch (...) |
| 535 | { |
| 536 | this->__set_badbit_and_consider_rethrow(); |
| 537 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 538 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 539 | return *this; |
| 540 | } |
| 541 | |
| 542 | template <class _CharT, class _Traits> |
| 543 | basic_ostream<_CharT, _Traits>& |
| 544 | basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) |
| 545 | { |
| 546 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 547 | try |
| 548 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 549 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 550 | sentry __s(*this); |
| 551 | if (__s) |
| 552 | { |
| 553 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 554 | const _F& __f = use_facet<_F>(this->getloc()); |
| 555 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 556 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 557 | } |
| 558 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 559 | } |
| 560 | catch (...) |
| 561 | { |
| 562 | this->__set_badbit_and_consider_rethrow(); |
| 563 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 564 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 565 | return *this; |
| 566 | } |
| 567 | |
| 568 | template <class _CharT, class _Traits> |
| 569 | basic_ostream<_CharT, _Traits>& |
| 570 | basic_ostream<_CharT, _Traits>::operator<<(long long __n) |
| 571 | { |
| 572 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 573 | try |
| 574 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 575 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 576 | sentry __s(*this); |
| 577 | if (__s) |
| 578 | { |
| 579 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 580 | const _F& __f = use_facet<_F>(this->getloc()); |
| 581 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 582 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 583 | } |
| 584 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 585 | } |
| 586 | catch (...) |
| 587 | { |
| 588 | this->__set_badbit_and_consider_rethrow(); |
| 589 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 590 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 591 | return *this; |
| 592 | } |
| 593 | |
| 594 | template <class _CharT, class _Traits> |
| 595 | basic_ostream<_CharT, _Traits>& |
| 596 | basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) |
| 597 | { |
| 598 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 599 | try |
| 600 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 601 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 602 | sentry __s(*this); |
| 603 | if (__s) |
| 604 | { |
| 605 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 606 | const _F& __f = use_facet<_F>(this->getloc()); |
| 607 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 608 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 609 | } |
| 610 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 611 | } |
| 612 | catch (...) |
| 613 | { |
| 614 | this->__set_badbit_and_consider_rethrow(); |
| 615 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 616 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 617 | return *this; |
| 618 | } |
| 619 | |
| 620 | template <class _CharT, class _Traits> |
| 621 | basic_ostream<_CharT, _Traits>& |
| 622 | basic_ostream<_CharT, _Traits>::operator<<(float __n) |
| 623 | { |
| 624 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 625 | try |
| 626 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 627 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 628 | sentry __s(*this); |
| 629 | if (__s) |
| 630 | { |
| 631 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 632 | const _F& __f = use_facet<_F>(this->getloc()); |
| 633 | if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed()) |
| 634 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 635 | } |
| 636 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 637 | } |
| 638 | catch (...) |
| 639 | { |
| 640 | this->__set_badbit_and_consider_rethrow(); |
| 641 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 642 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 643 | return *this; |
| 644 | } |
| 645 | |
| 646 | template <class _CharT, class _Traits> |
| 647 | basic_ostream<_CharT, _Traits>& |
| 648 | basic_ostream<_CharT, _Traits>::operator<<(double __n) |
| 649 | { |
| 650 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 651 | try |
| 652 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 653 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 654 | sentry __s(*this); |
| 655 | if (__s) |
| 656 | { |
| 657 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 658 | const _F& __f = use_facet<_F>(this->getloc()); |
| 659 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 660 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 661 | } |
| 662 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 663 | } |
| 664 | catch (...) |
| 665 | { |
| 666 | this->__set_badbit_and_consider_rethrow(); |
| 667 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 668 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 669 | return *this; |
| 670 | } |
| 671 | |
| 672 | template <class _CharT, class _Traits> |
| 673 | basic_ostream<_CharT, _Traits>& |
| 674 | basic_ostream<_CharT, _Traits>::operator<<(long double __n) |
| 675 | { |
| 676 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 677 | try |
| 678 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 679 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 680 | sentry __s(*this); |
| 681 | if (__s) |
| 682 | { |
| 683 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 684 | const _F& __f = use_facet<_F>(this->getloc()); |
| 685 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 686 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 687 | } |
| 688 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 689 | } |
| 690 | catch (...) |
| 691 | { |
| 692 | this->__set_badbit_and_consider_rethrow(); |
| 693 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 694 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 695 | return *this; |
| 696 | } |
| 697 | |
| 698 | template <class _CharT, class _Traits> |
| 699 | basic_ostream<_CharT, _Traits>& |
| 700 | basic_ostream<_CharT, _Traits>::operator<<(const void* __n) |
| 701 | { |
| 702 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 703 | try |
| 704 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 705 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 706 | sentry __s(*this); |
| 707 | if (__s) |
| 708 | { |
| 709 | typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _F; |
| 710 | const _F& __f = use_facet<_F>(this->getloc()); |
| 711 | if (__f.put(*this, *this, this->fill(), __n).failed()) |
| 712 | this->setstate(ios_base::badbit | ios_base::failbit); |
| 713 | } |
| 714 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 715 | } |
| 716 | catch (...) |
| 717 | { |
| 718 | this->__set_badbit_and_consider_rethrow(); |
| 719 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 720 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 721 | return *this; |
| 722 | } |
| 723 | |
| 724 | template<class _CharT, class _Traits> |
| 725 | basic_ostream<_CharT, _Traits>& |
| 726 | operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) |
| 727 | { |
| 728 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 729 | try |
| 730 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 731 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 732 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 733 | if (__s) |
| 734 | { |
| 735 | typedef ostreambuf_iterator<_CharT, _Traits> _I; |
| 736 | if (__pad_and_output(_I(__os), |
| 737 | &__c, |
| 738 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 739 | &__c + 1 : |
| 740 | &__c, |
| 741 | &__c + 1, |
| 742 | __os, |
| 743 | __os.fill()).failed()) |
| 744 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 745 | } |
| 746 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 747 | } |
| 748 | catch (...) |
| 749 | { |
| 750 | __os.__set_badbit_and_consider_rethrow(); |
| 751 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 752 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 753 | return __os; |
| 754 | } |
| 755 | |
| 756 | template<class _CharT, class _Traits> |
| 757 | basic_ostream<_CharT, _Traits>& |
| 758 | operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) |
| 759 | { |
| 760 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 761 | try |
| 762 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 763 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 764 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 765 | if (__s) |
| 766 | { |
| 767 | _CharT __c = __os.widen(__cn); |
| 768 | typedef ostreambuf_iterator<_CharT, _Traits> _I; |
| 769 | if (__pad_and_output(_I(__os), |
| 770 | &__c, |
| 771 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 772 | &__c + 1 : |
| 773 | &__c, |
| 774 | &__c + 1, |
| 775 | __os, |
| 776 | __os.fill()).failed()) |
| 777 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 778 | } |
| 779 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 780 | } |
| 781 | catch (...) |
| 782 | { |
| 783 | __os.__set_badbit_and_consider_rethrow(); |
| 784 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 785 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 786 | return __os; |
| 787 | } |
| 788 | |
| 789 | template<class _Traits> |
| 790 | basic_ostream<char, _Traits>& |
| 791 | operator<<(basic_ostream<char, _Traits>& __os, char __c) |
| 792 | { |
| 793 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 794 | try |
| 795 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 796 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 797 | typename basic_ostream<char, _Traits>::sentry __s(__os); |
| 798 | if (__s) |
| 799 | { |
| 800 | typedef ostreambuf_iterator<char, _Traits> _I; |
| 801 | if (__pad_and_output(_I(__os), |
| 802 | &__c, |
| 803 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 804 | &__c + 1 : |
| 805 | &__c, |
| 806 | &__c + 1, |
| 807 | __os, |
| 808 | __os.fill()).failed()) |
| 809 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 810 | } |
| 811 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 812 | } |
| 813 | catch (...) |
| 814 | { |
| 815 | __os.__set_badbit_and_consider_rethrow(); |
| 816 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 817 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 818 | return __os; |
| 819 | } |
| 820 | |
| 821 | template<class _Traits> |
| 822 | basic_ostream<char, _Traits>& |
| 823 | operator<<(basic_ostream<char, _Traits>& __os, signed char __c) |
| 824 | { |
| 825 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 826 | try |
| 827 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 828 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 829 | typename basic_ostream<char, _Traits>::sentry __s(__os); |
| 830 | if (__s) |
| 831 | { |
| 832 | typedef ostreambuf_iterator<char, _Traits> _I; |
| 833 | if (__pad_and_output(_I(__os), |
| 834 | (char*)&__c, |
| 835 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 836 | (char*)&__c + 1 : |
| 837 | (char*)&__c, |
| 838 | (char*)&__c + 1, |
| 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 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [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, unsigned char __c) |
| 856 | { |
| 857 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 858 | try |
| 859 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 860 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 861 | typename basic_ostream<char, _Traits>::sentry __s(__os); |
| 862 | if (__s) |
| 863 | { |
| 864 | typedef ostreambuf_iterator<char, _Traits> _I; |
| 865 | if (__pad_and_output(_I(__os), |
| 866 | (char*)&__c, |
| 867 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 868 | (char*)&__c + 1 : |
| 869 | (char*)&__c, |
| 870 | (char*)&__c + 1, |
| 871 | __os, |
| 872 | __os.fill()).failed()) |
| 873 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 874 | } |
| 875 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 876 | } |
| 877 | catch (...) |
| 878 | { |
| 879 | __os.__set_badbit_and_consider_rethrow(); |
| 880 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 881 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 882 | return __os; |
| 883 | } |
| 884 | |
| 885 | template<class _CharT, class _Traits> |
| 886 | basic_ostream<_CharT, _Traits>& |
| 887 | operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) |
| 888 | { |
| 889 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 890 | try |
| 891 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 892 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 893 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 894 | if (__s) |
| 895 | { |
| 896 | typedef ostreambuf_iterator<_CharT, _Traits> _I; |
| 897 | size_t __len = _Traits::length(__str); |
| 898 | if (__pad_and_output(_I(__os), |
| 899 | __str, |
| 900 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 901 | __str + __len : |
| 902 | __str, |
| 903 | __str + __len, |
| 904 | __os, |
| 905 | __os.fill()).failed()) |
| 906 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 907 | } |
| 908 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 909 | } |
| 910 | catch (...) |
| 911 | { |
| 912 | __os.__set_badbit_and_consider_rethrow(); |
| 913 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 914 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 915 | return __os; |
| 916 | } |
| 917 | |
| 918 | template<class _CharT, class _Traits> |
| 919 | basic_ostream<_CharT, _Traits>& |
| 920 | operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) |
| 921 | { |
| 922 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 923 | try |
| 924 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 925 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 926 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 927 | if (__s) |
| 928 | { |
| 929 | typedef ostreambuf_iterator<_CharT, _Traits> _I; |
| 930 | size_t __len = char_traits<char>::length(__strn); |
| 931 | const int __bs = 100; |
| 932 | _CharT __wbb[__bs]; |
| 933 | _CharT* __wb = __wbb; |
| 934 | unique_ptr<_CharT, void(*)(void*)> __h(0, free); |
| 935 | if (__len > __bs) |
| 936 | { |
| 937 | __wb = (_CharT*)malloc(__len*sizeof(_CharT)); |
| 938 | if (__wb == 0) |
| 939 | __throw_bad_alloc(); |
| 940 | __h.reset(__wb); |
| 941 | } |
| 942 | for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p) |
| 943 | *__p = __os.widen(*__strn); |
| 944 | if (__pad_and_output(_I(__os), |
| 945 | __wb, |
| 946 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 947 | __wb + __len : |
| 948 | __wb, |
| 949 | __wb + __len, |
| 950 | __os, |
| 951 | __os.fill()).failed()) |
| 952 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 953 | } |
| 954 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 955 | } |
| 956 | catch (...) |
| 957 | { |
| 958 | __os.__set_badbit_and_consider_rethrow(); |
| 959 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 960 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 961 | return __os; |
| 962 | } |
| 963 | |
| 964 | template<class _Traits> |
| 965 | basic_ostream<char, _Traits>& |
| 966 | operator<<(basic_ostream<char, _Traits>& __os, const char* __str) |
| 967 | { |
| 968 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 969 | try |
| 970 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 971 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 972 | typename basic_ostream<char, _Traits>::sentry __s(__os); |
| 973 | if (__s) |
| 974 | { |
| 975 | typedef ostreambuf_iterator<char, _Traits> _I; |
| 976 | size_t __len = _Traits::length(__str); |
| 977 | if (__pad_and_output(_I(__os), |
| 978 | __str, |
| 979 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 980 | __str + __len : |
| 981 | __str, |
| 982 | __str + __len, |
| 983 | __os, |
| 984 | __os.fill()).failed()) |
| 985 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 986 | } |
| 987 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 988 | } |
| 989 | catch (...) |
| 990 | { |
| 991 | __os.__set_badbit_and_consider_rethrow(); |
| 992 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 993 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 994 | return __os; |
| 995 | } |
| 996 | |
| 997 | template<class _Traits> |
| 998 | basic_ostream<char, _Traits>& |
| 999 | operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str) |
| 1000 | { |
| 1001 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1002 | try |
| 1003 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1004 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1005 | typename basic_ostream<char, _Traits>::sentry __s(__os); |
| 1006 | if (__s) |
| 1007 | { |
| 1008 | typedef ostreambuf_iterator<char, _Traits> _I; |
| 1009 | size_t __len = _Traits::length((const char*)__str); |
| 1010 | if (__pad_and_output(_I(__os), |
| 1011 | (const char*)__str, |
| 1012 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 1013 | (const char*)__str + __len : |
| 1014 | (const char*)__str, |
| 1015 | (const char*)__str + __len, |
| 1016 | __os, |
| 1017 | __os.fill()).failed()) |
| 1018 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 1019 | } |
| 1020 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1021 | } |
| 1022 | catch (...) |
| 1023 | { |
| 1024 | __os.__set_badbit_and_consider_rethrow(); |
| 1025 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1026 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1027 | return __os; |
| 1028 | } |
| 1029 | |
| 1030 | template<class _Traits> |
| 1031 | basic_ostream<char, _Traits>& |
| 1032 | operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) |
| 1033 | { |
| 1034 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1035 | try |
| 1036 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1037 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1038 | typename basic_ostream<char, _Traits>::sentry __s(__os); |
| 1039 | if (__s) |
| 1040 | { |
| 1041 | typedef ostreambuf_iterator<char, _Traits> _I; |
| 1042 | size_t __len = _Traits::length((const char*)__str); |
| 1043 | if (__pad_and_output(_I(__os), |
| 1044 | (const char*)__str, |
| 1045 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 1046 | (const char*)__str + __len : |
| 1047 | (const char*)__str, |
| 1048 | (const char*)__str + __len, |
| 1049 | __os, |
| 1050 | __os.fill()).failed()) |
| 1051 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 1052 | } |
| 1053 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1054 | } |
| 1055 | catch (...) |
| 1056 | { |
| 1057 | __os.__set_badbit_and_consider_rethrow(); |
| 1058 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1059 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1060 | return __os; |
| 1061 | } |
| 1062 | |
| 1063 | template <class _CharT, class _Traits> |
| 1064 | basic_ostream<_CharT, _Traits>& |
| 1065 | basic_ostream<_CharT, _Traits>::put(char_type __c) |
| 1066 | { |
| 1067 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1068 | try |
| 1069 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1070 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1071 | sentry __s(*this); |
| 1072 | if (__s) |
| 1073 | { |
| 1074 | typedef ostreambuf_iterator<_CharT, _Traits> _O; |
| 1075 | _O __o(*this); |
| 1076 | *__o = __c; |
| 1077 | if (__o.failed()) |
| 1078 | this->setstate(ios_base::badbit); |
| 1079 | } |
| 1080 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1081 | } |
| 1082 | catch (...) |
| 1083 | { |
| 1084 | this->__set_badbit_and_consider_rethrow(); |
| 1085 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1086 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1087 | return *this; |
| 1088 | } |
| 1089 | |
| 1090 | template <class _CharT, class _Traits> |
| 1091 | basic_ostream<_CharT, _Traits>& |
| 1092 | basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) |
| 1093 | { |
| 1094 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1095 | try |
| 1096 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1097 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1098 | sentry __sen(*this); |
| 1099 | if (__sen && __n) |
| 1100 | { |
| 1101 | typedef ostreambuf_iterator<_CharT, _Traits> _O; |
| 1102 | _O __o(*this); |
| 1103 | for (; __n; --__n, ++__o, ++__s) |
| 1104 | { |
| 1105 | *__o = *__s; |
| 1106 | if (__o.failed()) |
| 1107 | { |
| 1108 | this->setstate(ios_base::badbit); |
| 1109 | break; |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1114 | } |
| 1115 | catch (...) |
| 1116 | { |
| 1117 | this->__set_badbit_and_consider_rethrow(); |
| 1118 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1119 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1120 | return *this; |
| 1121 | } |
| 1122 | |
| 1123 | template <class _CharT, class _Traits> |
| 1124 | basic_ostream<_CharT, _Traits>& |
| 1125 | basic_ostream<_CharT, _Traits>::flush() |
| 1126 | { |
| 1127 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1128 | try |
| 1129 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1130 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1131 | if (this->rdbuf()) |
| 1132 | { |
| 1133 | sentry __s(*this); |
| 1134 | if (__s) |
| 1135 | { |
| 1136 | if (this->rdbuf()->pubsync() == -1) |
| 1137 | this->setstate(ios_base::badbit); |
| 1138 | } |
| 1139 | } |
| 1140 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1141 | } |
| 1142 | catch (...) |
| 1143 | { |
| 1144 | this->__set_badbit_and_consider_rethrow(); |
| 1145 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1146 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1147 | return *this; |
| 1148 | } |
| 1149 | |
| 1150 | template <class _CharT, class _Traits> |
| 1151 | inline _LIBCPP_INLINE_VISIBILITY |
| 1152 | typename basic_ostream<_CharT, _Traits>::pos_type |
| 1153 | basic_ostream<_CharT, _Traits>::tellp() |
| 1154 | { |
| 1155 | if (this->fail()) |
| 1156 | return pos_type(-1); |
| 1157 | return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); |
| 1158 | } |
| 1159 | |
| 1160 | template <class _CharT, class _Traits> |
| 1161 | inline _LIBCPP_INLINE_VISIBILITY |
| 1162 | basic_ostream<_CharT, _Traits>& |
| 1163 | basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) |
| 1164 | { |
| 1165 | if (!this->fail()) |
| 1166 | { |
| 1167 | if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) |
| 1168 | this->setstate(ios_base::failbit); |
| 1169 | } |
| 1170 | return *this; |
| 1171 | } |
| 1172 | |
| 1173 | template <class _CharT, class _Traits> |
| 1174 | inline _LIBCPP_INLINE_VISIBILITY |
| 1175 | basic_ostream<_CharT, _Traits>& |
| 1176 | basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) |
| 1177 | { |
| 1178 | if (!this->fail()) |
| 1179 | this->rdbuf()->pubseekoff(__off, __dir, ios_base::out); |
| 1180 | return *this; |
| 1181 | } |
| 1182 | |
| 1183 | template <class _CharT, class _Traits> |
| 1184 | inline _LIBCPP_INLINE_VISIBILITY |
| 1185 | basic_ostream<_CharT, _Traits>& |
| 1186 | endl(basic_ostream<_CharT, _Traits>& __os) |
| 1187 | { |
| 1188 | __os.put(__os.widen('\n')); |
| 1189 | __os.flush(); |
| 1190 | return __os; |
| 1191 | } |
| 1192 | |
| 1193 | template <class _CharT, class _Traits> |
| 1194 | inline _LIBCPP_INLINE_VISIBILITY |
| 1195 | basic_ostream<_CharT, _Traits>& |
| 1196 | ends(basic_ostream<_CharT, _Traits>& __os) |
| 1197 | { |
| 1198 | __os.put(_CharT()); |
| 1199 | return __os; |
| 1200 | } |
| 1201 | |
| 1202 | template <class _CharT, class _Traits> |
| 1203 | inline _LIBCPP_INLINE_VISIBILITY |
| 1204 | basic_ostream<_CharT, _Traits>& |
| 1205 | flush(basic_ostream<_CharT, _Traits>& __os) |
| 1206 | { |
| 1207 | __os.flush(); |
| 1208 | return __os; |
| 1209 | } |
| 1210 | |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1211 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1212 | |
| 1213 | template <class _Stream, class _Tp> |
| 1214 | inline _LIBCPP_INLINE_VISIBILITY |
| 1215 | typename enable_if |
| 1216 | < |
| 1217 | !is_lvalue_reference<_Stream>::value && |
| 1218 | is_base_of<ios_base, _Stream>::value, |
| 1219 | _Stream& |
| 1220 | >::type |
| 1221 | operator<<(_Stream&& __os, const _Tp& __x) |
| 1222 | { |
| 1223 | __os << __x; |
| 1224 | return __os; |
| 1225 | } |
| 1226 | |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1227 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1228 | |
| 1229 | template<class _CharT, class _Traits, class _Allocator> |
| 1230 | basic_ostream<_CharT, _Traits>& |
| 1231 | operator<<(basic_ostream<_CharT, _Traits>& __os, |
| 1232 | const basic_string<_CharT, _Traits, _Allocator>& __str) |
| 1233 | { |
| 1234 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1235 | try |
| 1236 | { |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1237 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1238 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 1239 | if (__s) |
| 1240 | { |
| 1241 | typedef ostreambuf_iterator<_CharT, _Traits> _I; |
| 1242 | size_t __len = __str.size(); |
| 1243 | if (__pad_and_output(_I(__os), |
| 1244 | __str.data(), |
| 1245 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? |
| 1246 | __str.data() + __len : |
| 1247 | __str.data(), |
| 1248 | __str.data() + __len, |
| 1249 | __os, |
| 1250 | __os.fill()).failed()) |
| 1251 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 1252 | } |
| 1253 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1254 | } |
| 1255 | catch (...) |
| 1256 | { |
| 1257 | __os.__set_badbit_and_consider_rethrow(); |
| 1258 | } |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1259 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1260 | return __os; |
| 1261 | } |
| 1262 | |
| 1263 | template <class _CharT, class _Traits> |
| 1264 | inline _LIBCPP_INLINE_VISIBILITY |
| 1265 | basic_ostream<_CharT, _Traits>& |
| 1266 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) |
| 1267 | { |
| 1268 | return __os << __ec.category().name() << ':' << __ec.value(); |
| 1269 | } |
| 1270 | |
| 1271 | template<class _CharT, class _Traits, class _Y> |
| 1272 | inline _LIBCPP_INLINE_VISIBILITY |
| 1273 | basic_ostream<_CharT, _Traits>& |
| 1274 | operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Y> const& __p) |
| 1275 | { |
| 1276 | return __os << __p.get(); |
| 1277 | } |
| 1278 | |
| 1279 | template <class _CharT, class _Traits, size_t _Size> |
| 1280 | basic_ostream<_CharT, _Traits>& |
Howard Hinnant | fa65ab6 | 2011-04-05 14:55:28 +0000 | [diff] [blame] | 1281 | operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1282 | { |
| 1283 | return __os << __x.template to_string<_CharT, _Traits> |
| 1284 | (use_facet<ctype<_CharT> >(__os.getloc()).widen('0'), |
| 1285 | use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); |
| 1286 | } |
| 1287 | |
| 1288 | extern template class basic_ostream<char>; |
| 1289 | extern template class basic_ostream<wchar_t>; |
| 1290 | |
| 1291 | _LIBCPP_END_NAMESPACE_STD |
| 1292 | |
| 1293 | #endif // _LIBCPP_OSTREAM |