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