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