Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- istream ----------------------------------===// |
| 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 | // |
| 6 | // This file is distributed under the University of Illinois Open Source |
| 7 | // License. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_ISTREAM |
| 12 | #define _LIBCPP_ISTREAM |
| 13 | |
| 14 | /* |
| 15 | istream synopsis |
| 16 | |
| 17 | template <class charT, class traits = char_traits<charT> > |
| 18 | class basic_istream |
| 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.1.1.1 Constructor/destructor: |
| 30 | explicit basic_istream(basic_streambuf<char_type, traits_type>* sb); |
| 31 | basic_istream(basic_istream&& rhs); |
| 32 | virtual ~basic_istream(); |
| 33 | |
| 34 | // 27.7.1.1.2 Assign/swap: |
| 35 | basic_istream& operator=(basic_istream&& rhs); |
| 36 | void swap(basic_istream& rhs); |
| 37 | |
| 38 | // 27.7.1.1.3 Prefix/suffix: |
| 39 | class sentry; |
| 40 | |
| 41 | // 27.7.1.2 Formatted input: |
| 42 | basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); |
| 43 | basic_istream& operator>>(basic_ios<char_type, traits_type>& |
| 44 | (*pf)(basic_ios<char_type, traits_type>&)); |
| 45 | basic_istream& operator>>(ios_base& (*pf)(ios_base&)); |
| 46 | basic_istream& operator>>(basic_streambuf<char_type, traits_type>* sb); |
| 47 | basic_istream& operator>>(bool& n); |
| 48 | basic_istream& operator>>(short& n); |
| 49 | basic_istream& operator>>(unsigned short& n); |
| 50 | basic_istream& operator>>(int& n); |
| 51 | basic_istream& operator>>(unsigned int& n); |
| 52 | basic_istream& operator>>(long& n); |
| 53 | basic_istream& operator>>(unsigned long& n); |
| 54 | basic_istream& operator>>(long long& n); |
| 55 | basic_istream& operator>>(unsigned long long& n); |
| 56 | basic_istream& operator>>(float& f); |
| 57 | basic_istream& operator>>(double& f); |
| 58 | basic_istream& operator>>(long double& f); |
| 59 | basic_istream& operator>>(void*& p); |
| 60 | |
| 61 | // 27.7.1.3 Unformatted input: |
| 62 | streamsize gcount() const; |
| 63 | int_type get(); |
| 64 | basic_istream& get(char_type& c); |
| 65 | basic_istream& get(char_type* s, streamsize n); |
| 66 | basic_istream& get(char_type* s, streamsize n, char_type delim); |
| 67 | basic_istream& get(basic_streambuf<char_type,traits_type>& sb); |
| 68 | basic_istream& get(basic_streambuf<char_type,traits_type>& sb, char_type delim); |
| 69 | |
| 70 | basic_istream& getline(char_type* s, streamsize n); |
| 71 | basic_istream& getline(char_type* s, streamsize n, char_type delim); |
| 72 | |
| 73 | basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof()); |
| 74 | int_type peek(); |
| 75 | basic_istream& read (char_type* s, streamsize n); |
| 76 | streamsize readsome(char_type* s, streamsize n); |
| 77 | |
| 78 | basic_istream& putback(char_type c); |
| 79 | basic_istream& unget(); |
| 80 | int sync(); |
| 81 | |
| 82 | pos_type tellg(); |
| 83 | basic_istream& seekg(pos_type); |
| 84 | basic_istream& seekg(off_type, ios_base::seekdir); |
| 85 | }; |
| 86 | |
| 87 | // 27.7.1.2.3 character extraction templates: |
| 88 | template<class charT, class traits> |
| 89 | basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT&); |
| 90 | |
| 91 | template<class traits> |
| 92 | basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char&); |
| 93 | |
| 94 | template<class traits> |
| 95 | basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char&); |
| 96 | |
| 97 | template<class charT, class traits> |
| 98 | basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT*); |
| 99 | |
| 100 | template<class traits> |
| 101 | basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char*); |
| 102 | |
| 103 | template<class traits> |
| 104 | basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char*); |
| 105 | |
| 106 | template <class charT, class traits> |
| 107 | void |
| 108 | swap(basic_istream<charT, traits>& x, basic_istream<charT, traits>& y); |
| 109 | |
| 110 | typedef basic_istream<char> istream; |
| 111 | typedef basic_istream<wchar_t> wistream; |
| 112 | |
| 113 | template <class charT, class traits = char_traits<charT> > |
| 114 | class basic_iostream : |
| 115 | public basic_istream<charT,traits>, |
| 116 | public basic_ostream<charT,traits> |
| 117 | { |
| 118 | public: |
| 119 | // types: |
| 120 | typedef charT char_type; |
| 121 | typedef traits traits_type; |
| 122 | typedef typename traits_type::int_type int_type; |
| 123 | typedef typename traits_type::pos_type pos_type; |
| 124 | typedef typename traits_type::off_type off_type; |
| 125 | |
| 126 | // constructor/destructor |
| 127 | explicit basic_iostream(basic_streambuf<char_type, traits_type>* sb); |
| 128 | basic_iostream(basic_iostream&& rhs); |
| 129 | virtual ~basic_iostream(); |
| 130 | |
| 131 | // assign/swap |
| 132 | basic_iostream& operator=(basic_iostream&& rhs); |
| 133 | void swap(basic_iostream& rhs); |
| 134 | }; |
| 135 | |
| 136 | template <class charT, class traits> |
| 137 | void |
| 138 | swap(basic_iostream<charT, traits>& x, basic_iostream<charT, traits>& y); |
| 139 | |
| 140 | typedef basic_iostream<char> iostream; |
| 141 | typedef basic_iostream<wchar_t> wiostream; |
| 142 | |
| 143 | template <class charT, class traits> |
| 144 | basic_istream<charT,traits>& |
| 145 | ws(basic_istream<charT,traits>& is); |
| 146 | |
| 147 | template <class charT, class traits, class T> |
| 148 | basic_istream<charT, traits>& |
| 149 | operator>>(basic_istream<charT, traits>&& is, T& x); |
| 150 | |
| 151 | } // std |
| 152 | |
| 153 | */ |
| 154 | |
| 155 | #include <__config> |
| 156 | #include <ostream> |
| 157 | |
| 158 | #pragma GCC system_header |
| 159 | |
| 160 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 161 | |
| 162 | template <class _CharT, class _Traits> |
| 163 | class basic_istream |
| 164 | : virtual public basic_ios<_CharT, _Traits> |
| 165 | { |
| 166 | streamsize __gc_; |
| 167 | public: |
| 168 | // types (inherited from basic_ios (27.5.4)): |
| 169 | typedef _CharT char_type; |
| 170 | typedef _Traits traits_type; |
| 171 | typedef typename traits_type::int_type int_type; |
| 172 | typedef typename traits_type::pos_type pos_type; |
| 173 | typedef typename traits_type::off_type off_type; |
| 174 | |
| 175 | // 27.7.1.1.1 Constructor/destructor: |
| 176 | explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb); |
| 177 | virtual ~basic_istream(); |
| 178 | protected: |
| 179 | #ifdef _LIBCPP_MOVE |
| 180 | basic_istream(basic_istream&& __rhs); |
| 181 | #endif |
| 182 | |
| 183 | // 27.7.1.1.2 Assign/swap: |
| 184 | #ifdef _LIBCPP_MOVE |
| 185 | basic_istream& operator=(basic_istream&& __rhs); |
| 186 | #endif |
| 187 | void swap(basic_istream& __rhs); |
| 188 | public: |
| 189 | |
| 190 | // 27.7.1.1.3 Prefix/suffix: |
| 191 | class sentry; |
| 192 | |
| 193 | // 27.7.1.2 Formatted input: |
| 194 | basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)); |
| 195 | basic_istream& operator>>(basic_ios<char_type, traits_type>& |
| 196 | (*__pf)(basic_ios<char_type, traits_type>&)); |
| 197 | basic_istream& operator>>(ios_base& (*__pf)(ios_base&)); |
| 198 | basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb); |
| 199 | basic_istream& operator>>(bool& __n); |
| 200 | basic_istream& operator>>(short& __n); |
| 201 | basic_istream& operator>>(unsigned short& __n); |
| 202 | basic_istream& operator>>(int& __n); |
| 203 | basic_istream& operator>>(unsigned int& __n); |
| 204 | basic_istream& operator>>(long& __n); |
| 205 | basic_istream& operator>>(unsigned long& __n); |
| 206 | basic_istream& operator>>(long long& __n); |
| 207 | basic_istream& operator>>(unsigned long long& __n); |
| 208 | basic_istream& operator>>(float& __f); |
| 209 | basic_istream& operator>>(double& __f); |
| 210 | basic_istream& operator>>(long double& __f); |
| 211 | basic_istream& operator>>(void*& __p); |
| 212 | |
| 213 | // 27.7.1.3 Unformatted input: |
| 214 | streamsize gcount() const {return __gc_;} |
| 215 | int_type get(); |
| 216 | basic_istream& get(char_type& __c); |
| 217 | basic_istream& get(char_type* __s, streamsize __n); |
| 218 | basic_istream& get(char_type* __s, streamsize __n, char_type __dlm); |
| 219 | basic_istream& get(basic_streambuf<char_type, traits_type>& __sb); |
| 220 | basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm); |
| 221 | |
| 222 | basic_istream& getline(char_type* __s, streamsize __n); |
| 223 | basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm); |
| 224 | |
| 225 | basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof()); |
| 226 | int_type peek(); |
| 227 | basic_istream& read (char_type* __s, streamsize __n); |
| 228 | streamsize readsome(char_type* __s, streamsize __n); |
| 229 | |
| 230 | basic_istream& putback(char_type __c); |
| 231 | basic_istream& unget(); |
| 232 | int sync(); |
| 233 | |
| 234 | pos_type tellg(); |
| 235 | basic_istream& seekg(pos_type __pos); |
| 236 | basic_istream& seekg(off_type __off, ios_base::seekdir __dir); |
| 237 | }; |
| 238 | |
| 239 | template <class _CharT, class _Traits> |
| 240 | class basic_istream<_CharT, _Traits>::sentry |
| 241 | { |
| 242 | bool __ok_; |
| 243 | |
| 244 | sentry(const sentry&); // = delete; |
| 245 | sentry& operator=(const sentry&); // = delete; |
| 246 | |
| 247 | public: |
| 248 | explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); |
| 249 | // ~sentry() = default; |
| 250 | |
| 251 | // explicit |
| 252 | operator bool() const {return __ok_;} |
| 253 | }; |
| 254 | |
| 255 | template <class _CharT, class _Traits> |
| 256 | basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is, |
| 257 | bool __noskipws) |
| 258 | : __ok_(false) |
| 259 | { |
| 260 | if (__is.good()) |
| 261 | { |
| 262 | if (__is.tie()) |
| 263 | __is.tie()->flush(); |
| 264 | if (!__noskipws && (__is.flags() & ios_base::skipws)) |
| 265 | { |
| 266 | typedef istreambuf_iterator<_CharT, _Traits> _I; |
| 267 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
| 268 | _I __i(__is); |
| 269 | _I __eof; |
| 270 | for (; __i != __eof; ++__i) |
| 271 | if (!__ct.is(__ct.space, *__i)) |
| 272 | break; |
| 273 | if (__i == __eof) |
| 274 | __is.setstate(ios_base::failbit | ios_base::eofbit); |
| 275 | } |
| 276 | __ok_ = __is.good(); |
| 277 | } |
| 278 | else |
| 279 | __is.setstate(ios_base::failbit); |
| 280 | } |
| 281 | |
| 282 | template <class _CharT, class _Traits> |
| 283 | inline _LIBCPP_INLINE_VISIBILITY |
| 284 | basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf<char_type, traits_type>* __sb) |
| 285 | : __gc_(0) |
| 286 | { |
| 287 | this->init(__sb); |
| 288 | } |
| 289 | |
| 290 | #ifdef _LIBCPP_MOVE |
| 291 | |
| 292 | template <class _CharT, class _Traits> |
| 293 | inline _LIBCPP_INLINE_VISIBILITY |
| 294 | basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) |
| 295 | : __gc_(__rhs.__gc_) |
| 296 | { |
| 297 | __rhs.__gc_ = 0; |
| 298 | this->move(__rhs); |
| 299 | } |
| 300 | |
| 301 | template <class _CharT, class _Traits> |
| 302 | inline _LIBCPP_INLINE_VISIBILITY |
| 303 | basic_istream<_CharT, _Traits>& |
| 304 | basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs) |
| 305 | { |
| 306 | swap(__rhs); |
| 307 | return *this; |
| 308 | } |
| 309 | |
| 310 | #endif |
| 311 | |
| 312 | template <class _CharT, class _Traits> |
| 313 | basic_istream<_CharT, _Traits>::~basic_istream() |
| 314 | { |
| 315 | } |
| 316 | |
| 317 | template <class _CharT, class _Traits> |
| 318 | inline _LIBCPP_INLINE_VISIBILITY |
| 319 | void |
| 320 | basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs) |
| 321 | { |
| 322 | _STD::swap(__gc_, __rhs.__gc_); |
| 323 | basic_ios<char_type, traits_type>::swap(__rhs); |
| 324 | } |
| 325 | |
| 326 | template <class _CharT, class _Traits> |
| 327 | basic_istream<_CharT, _Traits>& |
| 328 | basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n) |
| 329 | { |
| 330 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 331 | try |
| 332 | { |
| 333 | #endif |
| 334 | sentry __s(*this); |
| 335 | if (__s) |
| 336 | { |
| 337 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 338 | typedef num_get<char_type, _I> _F; |
| 339 | ios_base::iostate __err = ios_base::goodbit; |
| 340 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 341 | this->setstate(__err); |
| 342 | } |
| 343 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 344 | } |
| 345 | catch (...) |
| 346 | { |
| 347 | this->__set_badbit_and_consider_rethrow(); |
| 348 | } |
| 349 | #endif |
| 350 | return *this; |
| 351 | } |
| 352 | |
| 353 | template <class _CharT, class _Traits> |
| 354 | basic_istream<_CharT, _Traits>& |
| 355 | basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n) |
| 356 | { |
| 357 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 358 | try |
| 359 | { |
| 360 | #endif |
| 361 | sentry __s(*this); |
| 362 | if (__s) |
| 363 | { |
| 364 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 365 | typedef num_get<char_type, _I> _F; |
| 366 | ios_base::iostate __err = ios_base::goodbit; |
| 367 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 368 | this->setstate(__err); |
| 369 | } |
| 370 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 371 | } |
| 372 | catch (...) |
| 373 | { |
| 374 | this->__set_badbit_and_consider_rethrow(); |
| 375 | } |
| 376 | #endif |
| 377 | return *this; |
| 378 | } |
| 379 | |
| 380 | template <class _CharT, class _Traits> |
| 381 | basic_istream<_CharT, _Traits>& |
| 382 | basic_istream<_CharT, _Traits>::operator>>(long& __n) |
| 383 | { |
| 384 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 385 | try |
| 386 | { |
| 387 | #endif |
| 388 | sentry __s(*this); |
| 389 | if (__s) |
| 390 | { |
| 391 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 392 | typedef num_get<char_type, _I> _F; |
| 393 | ios_base::iostate __err = ios_base::goodbit; |
| 394 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 395 | this->setstate(__err); |
| 396 | } |
| 397 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 398 | } |
| 399 | catch (...) |
| 400 | { |
| 401 | this->__set_badbit_and_consider_rethrow(); |
| 402 | } |
| 403 | #endif |
| 404 | return *this; |
| 405 | } |
| 406 | |
| 407 | template <class _CharT, class _Traits> |
| 408 | basic_istream<_CharT, _Traits>& |
| 409 | basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n) |
| 410 | { |
| 411 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 412 | try |
| 413 | { |
| 414 | #endif |
| 415 | sentry __s(*this); |
| 416 | if (__s) |
| 417 | { |
| 418 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 419 | typedef num_get<char_type, _I> _F; |
| 420 | ios_base::iostate __err = ios_base::goodbit; |
| 421 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 422 | this->setstate(__err); |
| 423 | } |
| 424 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 425 | } |
| 426 | catch (...) |
| 427 | { |
| 428 | this->__set_badbit_and_consider_rethrow(); |
| 429 | } |
| 430 | #endif |
| 431 | return *this; |
| 432 | } |
| 433 | |
| 434 | template <class _CharT, class _Traits> |
| 435 | basic_istream<_CharT, _Traits>& |
| 436 | basic_istream<_CharT, _Traits>::operator>>(long long& __n) |
| 437 | { |
| 438 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 439 | try |
| 440 | { |
| 441 | #endif |
| 442 | sentry __s(*this); |
| 443 | if (__s) |
| 444 | { |
| 445 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 446 | typedef num_get<char_type, _I> _F; |
| 447 | ios_base::iostate __err = ios_base::goodbit; |
| 448 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 449 | this->setstate(__err); |
| 450 | } |
| 451 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 452 | } |
| 453 | catch (...) |
| 454 | { |
| 455 | this->__set_badbit_and_consider_rethrow(); |
| 456 | } |
| 457 | #endif |
| 458 | return *this; |
| 459 | } |
| 460 | |
| 461 | template <class _CharT, class _Traits> |
| 462 | basic_istream<_CharT, _Traits>& |
| 463 | basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n) |
| 464 | { |
| 465 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 466 | try |
| 467 | { |
| 468 | #endif |
| 469 | sentry __s(*this); |
| 470 | if (__s) |
| 471 | { |
| 472 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 473 | typedef num_get<char_type, _I> _F; |
| 474 | ios_base::iostate __err = ios_base::goodbit; |
| 475 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 476 | this->setstate(__err); |
| 477 | } |
| 478 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 479 | } |
| 480 | catch (...) |
| 481 | { |
| 482 | this->__set_badbit_and_consider_rethrow(); |
| 483 | } |
| 484 | #endif |
| 485 | return *this; |
| 486 | } |
| 487 | |
| 488 | template <class _CharT, class _Traits> |
| 489 | basic_istream<_CharT, _Traits>& |
| 490 | basic_istream<_CharT, _Traits>::operator>>(float& __n) |
| 491 | { |
| 492 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 493 | try |
| 494 | { |
| 495 | #endif |
| 496 | sentry __s(*this); |
| 497 | if (__s) |
| 498 | { |
| 499 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 500 | typedef num_get<char_type, _I> _F; |
| 501 | ios_base::iostate __err = ios_base::goodbit; |
| 502 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 503 | this->setstate(__err); |
| 504 | } |
| 505 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 506 | } |
| 507 | catch (...) |
| 508 | { |
| 509 | this->__set_badbit_and_consider_rethrow(); |
| 510 | } |
| 511 | #endif |
| 512 | return *this; |
| 513 | } |
| 514 | |
| 515 | template <class _CharT, class _Traits> |
| 516 | basic_istream<_CharT, _Traits>& |
| 517 | basic_istream<_CharT, _Traits>::operator>>(double& __n) |
| 518 | { |
| 519 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 520 | try |
| 521 | { |
| 522 | #endif |
| 523 | sentry __s(*this); |
| 524 | if (__s) |
| 525 | { |
| 526 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 527 | typedef num_get<char_type, _I> _F; |
| 528 | ios_base::iostate __err = ios_base::goodbit; |
| 529 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 530 | this->setstate(__err); |
| 531 | } |
| 532 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 533 | } |
| 534 | catch (...) |
| 535 | { |
| 536 | this->__set_badbit_and_consider_rethrow(); |
| 537 | } |
| 538 | #endif |
| 539 | return *this; |
| 540 | } |
| 541 | |
| 542 | template <class _CharT, class _Traits> |
| 543 | basic_istream<_CharT, _Traits>& |
| 544 | basic_istream<_CharT, _Traits>::operator>>(long double& __n) |
| 545 | { |
| 546 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 547 | try |
| 548 | { |
| 549 | #endif |
| 550 | sentry __s(*this); |
| 551 | if (__s) |
| 552 | { |
| 553 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 554 | typedef num_get<char_type, _I> _F; |
| 555 | ios_base::iostate __err = ios_base::goodbit; |
| 556 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 557 | this->setstate(__err); |
| 558 | } |
| 559 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 560 | } |
| 561 | catch (...) |
| 562 | { |
| 563 | this->__set_badbit_and_consider_rethrow(); |
| 564 | } |
| 565 | #endif |
| 566 | return *this; |
| 567 | } |
| 568 | |
| 569 | template <class _CharT, class _Traits> |
| 570 | basic_istream<_CharT, _Traits>& |
| 571 | basic_istream<_CharT, _Traits>::operator>>(bool& __n) |
| 572 | { |
| 573 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 574 | try |
| 575 | { |
| 576 | #endif |
| 577 | sentry __s(*this); |
| 578 | if (__s) |
| 579 | { |
| 580 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 581 | typedef num_get<char_type, _I> _F; |
| 582 | ios_base::iostate __err = ios_base::goodbit; |
| 583 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 584 | this->setstate(__err); |
| 585 | } |
| 586 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 587 | } |
| 588 | catch (...) |
| 589 | { |
| 590 | this->__set_badbit_and_consider_rethrow(); |
| 591 | } |
| 592 | #endif |
| 593 | return *this; |
| 594 | } |
| 595 | |
| 596 | template <class _CharT, class _Traits> |
| 597 | basic_istream<_CharT, _Traits>& |
| 598 | basic_istream<_CharT, _Traits>::operator>>(void*& __n) |
| 599 | { |
| 600 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 601 | try |
| 602 | { |
| 603 | #endif |
| 604 | sentry __s(*this); |
| 605 | if (__s) |
| 606 | { |
| 607 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 608 | typedef num_get<char_type, _I> _F; |
| 609 | ios_base::iostate __err = ios_base::goodbit; |
| 610 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n); |
| 611 | this->setstate(__err); |
| 612 | } |
| 613 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 614 | } |
| 615 | catch (...) |
| 616 | { |
| 617 | this->__set_badbit_and_consider_rethrow(); |
| 618 | } |
| 619 | #endif |
| 620 | return *this; |
| 621 | } |
| 622 | |
| 623 | template <class _CharT, class _Traits> |
| 624 | basic_istream<_CharT, _Traits>& |
| 625 | basic_istream<_CharT, _Traits>::operator>>(short& __n) |
| 626 | { |
| 627 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 628 | try |
| 629 | { |
| 630 | #endif |
| 631 | sentry __s(*this); |
| 632 | if (__s) |
| 633 | { |
| 634 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 635 | typedef num_get<char_type, _I> _F; |
| 636 | ios_base::iostate __err = ios_base::goodbit; |
| 637 | long __temp; |
| 638 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __temp); |
| 639 | if (__temp < numeric_limits<short>::min()) |
| 640 | { |
| 641 | __err |= ios_base::failbit; |
| 642 | __n = numeric_limits<short>::min(); |
| 643 | } |
| 644 | else if (__temp > numeric_limits<short>::max()) |
| 645 | { |
| 646 | __err |= ios_base::failbit; |
| 647 | __n = numeric_limits<short>::max(); |
| 648 | } |
| 649 | else |
| 650 | __n = static_cast<short>(__temp); |
| 651 | this->setstate(__err); |
| 652 | } |
| 653 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 654 | } |
| 655 | catch (...) |
| 656 | { |
| 657 | this->__set_badbit_and_consider_rethrow(); |
| 658 | } |
| 659 | #endif |
| 660 | return *this; |
| 661 | } |
| 662 | |
| 663 | template <class _CharT, class _Traits> |
| 664 | basic_istream<_CharT, _Traits>& |
| 665 | basic_istream<_CharT, _Traits>::operator>>(int& __n) |
| 666 | { |
| 667 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 668 | try |
| 669 | { |
| 670 | #endif |
| 671 | sentry __s(*this); |
| 672 | if (__s) |
| 673 | { |
| 674 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 675 | typedef num_get<char_type, _I> _F; |
| 676 | ios_base::iostate __err = ios_base::goodbit; |
| 677 | long __temp; |
| 678 | use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __temp); |
| 679 | if (__temp < numeric_limits<int>::min()) |
| 680 | { |
| 681 | __err |= ios_base::failbit; |
| 682 | __n = numeric_limits<int>::min(); |
| 683 | } |
| 684 | else if (__temp > numeric_limits<int>::max()) |
| 685 | { |
| 686 | __err |= ios_base::failbit; |
| 687 | __n = numeric_limits<int>::max(); |
| 688 | } |
| 689 | else |
| 690 | __n = static_cast<int>(__temp); |
| 691 | this->setstate(__err); |
| 692 | } |
| 693 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 694 | } |
| 695 | catch (...) |
| 696 | { |
| 697 | this->__set_badbit_and_consider_rethrow(); |
| 698 | } |
| 699 | #endif |
| 700 | return *this; |
| 701 | } |
| 702 | |
| 703 | template <class _CharT, class _Traits> |
| 704 | inline _LIBCPP_INLINE_VISIBILITY |
| 705 | basic_istream<_CharT, _Traits>& |
| 706 | basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&)) |
| 707 | { |
| 708 | return __pf(*this); |
| 709 | } |
| 710 | |
| 711 | template <class _CharT, class _Traits> |
| 712 | inline _LIBCPP_INLINE_VISIBILITY |
| 713 | basic_istream<_CharT, _Traits>& |
| 714 | basic_istream<_CharT, _Traits>::operator>>(basic_ios<char_type, traits_type>& |
| 715 | (*__pf)(basic_ios<char_type, traits_type>&)) |
| 716 | { |
| 717 | __pf(*this); |
| 718 | return *this; |
| 719 | } |
| 720 | |
| 721 | template <class _CharT, class _Traits> |
| 722 | inline _LIBCPP_INLINE_VISIBILITY |
| 723 | basic_istream<_CharT, _Traits>& |
| 724 | basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&)) |
| 725 | { |
| 726 | __pf(*this); |
| 727 | return *this; |
| 728 | } |
| 729 | |
| 730 | template<class _CharT, class _Traits> |
| 731 | basic_istream<_CharT, _Traits>& |
| 732 | operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s) |
| 733 | { |
| 734 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 735 | try |
| 736 | { |
| 737 | #endif |
| 738 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 739 | if (__sen) |
| 740 | { |
| 741 | typedef istreambuf_iterator<_CharT, _Traits> _I; |
| 742 | streamsize __n = __is.width(); |
| 743 | if (__n == 0) |
| 744 | __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1; |
| 745 | streamsize __c = 0; |
| 746 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
| 747 | _I __i(__is); |
| 748 | _I __eof; |
| 749 | for (; __i != __eof && __c < __n-1; ++__i, ++__s, ++__c) |
| 750 | { |
| 751 | _CharT __ch = *__i; |
| 752 | if (__ct.is(__ct.space, __ch)) |
| 753 | break; |
| 754 | *__s = __ch; |
| 755 | } |
| 756 | *__s = _CharT(); |
| 757 | __is.width(0); |
| 758 | ios_base::iostate __err = ios_base::goodbit; |
| 759 | if (__i == __eof) |
| 760 | __err |= ios_base::eofbit; |
| 761 | if (__c == 0) |
| 762 | __err |= ios_base::failbit; |
| 763 | __is.setstate(__err); |
| 764 | } |
| 765 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 766 | } |
| 767 | catch (...) |
| 768 | { |
| 769 | __is.__set_badbit_and_consider_rethrow(); |
| 770 | } |
| 771 | #endif |
| 772 | return __is; |
| 773 | } |
| 774 | |
| 775 | template<class _Traits> |
| 776 | inline _LIBCPP_INLINE_VISIBILITY |
| 777 | basic_istream<char, _Traits>& |
| 778 | operator>>(basic_istream<char, _Traits>& __is, unsigned char* __s) |
| 779 | { |
| 780 | return __is >> (char*)__s; |
| 781 | } |
| 782 | |
| 783 | template<class _Traits> |
| 784 | inline _LIBCPP_INLINE_VISIBILITY |
| 785 | basic_istream<char, _Traits>& |
| 786 | operator>>(basic_istream<char, _Traits>& __is, signed char* __s) |
| 787 | { |
| 788 | return __is >> (char*)__s; |
| 789 | } |
| 790 | |
| 791 | template<class _CharT, class _Traits> |
| 792 | basic_istream<_CharT, _Traits>& |
| 793 | operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) |
| 794 | { |
| 795 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 796 | try |
| 797 | { |
| 798 | #endif |
| 799 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 800 | if (__sen) |
| 801 | { |
| 802 | typedef istreambuf_iterator<_CharT, _Traits> _I; |
| 803 | _I __i(__is); |
| 804 | _I __eof; |
| 805 | if (__i != __eof) |
| 806 | { |
| 807 | __c = *__i; |
| 808 | if (++__i == __eof) |
| 809 | __is.setstate(ios_base::eofbit); |
| 810 | } |
| 811 | else |
| 812 | __is.setstate(ios_base::eofbit | ios_base::failbit); |
| 813 | } |
| 814 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 815 | } |
| 816 | catch (...) |
| 817 | { |
| 818 | __is.__set_badbit_and_consider_rethrow(); |
| 819 | } |
| 820 | #endif |
| 821 | return __is; |
| 822 | } |
| 823 | |
| 824 | template<class _Traits> |
| 825 | inline _LIBCPP_INLINE_VISIBILITY |
| 826 | basic_istream<char, _Traits>& |
| 827 | operator>>(basic_istream<char, _Traits>& __is, unsigned char& __c) |
| 828 | { |
| 829 | return __is >> (char&)__c; |
| 830 | } |
| 831 | |
| 832 | template<class _Traits> |
| 833 | inline _LIBCPP_INLINE_VISIBILITY |
| 834 | basic_istream<char, _Traits>& |
| 835 | operator>>(basic_istream<char, _Traits>& __is, signed char& __c) |
| 836 | { |
| 837 | return __is >> (char&)__c; |
| 838 | } |
| 839 | |
| 840 | template<class _CharT, class _Traits> |
| 841 | basic_istream<_CharT, _Traits>& |
| 842 | basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb) |
| 843 | { |
| 844 | __gc_ = 0; |
| 845 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 846 | try |
| 847 | { |
| 848 | #endif |
| 849 | sentry __s(*this, true); |
| 850 | if (__s) |
| 851 | { |
| 852 | streamsize __c = 0; |
| 853 | if (__sb) |
| 854 | { |
| 855 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 856 | try |
| 857 | { |
| 858 | #endif |
| 859 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 860 | typedef ostreambuf_iterator<char_type, traits_type> _O; |
| 861 | _I __i(*this); |
| 862 | _I __eof; |
| 863 | _O __o(__sb); |
| 864 | for (; __i != __eof; ++__i, ++__o, ++__c) |
| 865 | { |
| 866 | *__o = *__i; |
| 867 | if (__o.failed()) |
| 868 | break; |
| 869 | } |
| 870 | ios_base::iostate __err = ios_base::goodbit; |
| 871 | if (__i == __eof) |
| 872 | __err |= ios_base::eofbit; |
| 873 | if (__c == 0) |
| 874 | __err |= ios_base::failbit; |
| 875 | this->setstate(__err); |
| 876 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 877 | } |
| 878 | catch (...) |
| 879 | { |
| 880 | if (__c == 0) |
| 881 | this->__set_failbit_and_consider_rethrow(); |
| 882 | } |
| 883 | #endif |
| 884 | } |
| 885 | else |
| 886 | this->setstate(ios_base::failbit); |
| 887 | __gc_ = __c; |
| 888 | } |
| 889 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 890 | } |
| 891 | catch (...) |
| 892 | { |
| 893 | this->__set_badbit_and_consider_rethrow(); |
| 894 | } |
| 895 | #endif |
| 896 | return *this; |
| 897 | } |
| 898 | |
| 899 | template<class _CharT, class _Traits> |
| 900 | typename basic_istream<_CharT, _Traits>::int_type |
| 901 | basic_istream<_CharT, _Traits>::get() |
| 902 | { |
| 903 | __gc_ = 0; |
| 904 | int_type __r = traits_type::eof(); |
| 905 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 906 | try |
| 907 | { |
| 908 | #endif |
| 909 | sentry __s(*this, true); |
| 910 | if (__s) |
| 911 | { |
| 912 | streamsize __c = 0; |
| 913 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 914 | _I __i(*this); |
| 915 | _I __eof; |
| 916 | ios_base::iostate __err = ios_base::goodbit; |
| 917 | if (__i != __eof) |
| 918 | { |
| 919 | __r = traits_type::to_int_type(*__i); |
| 920 | ++__c; |
| 921 | if (++__i == __eof) |
| 922 | __err |= ios_base::eofbit; |
| 923 | } |
| 924 | else |
| 925 | __err |= ios_base::failbit | ios_base::eofbit; |
| 926 | this->setstate(__err); |
| 927 | __gc_ = __c; |
| 928 | } |
| 929 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 930 | } |
| 931 | catch (...) |
| 932 | { |
| 933 | this->__set_badbit_and_consider_rethrow(); |
| 934 | } |
| 935 | #endif |
| 936 | return __r; |
| 937 | } |
| 938 | |
| 939 | template<class _CharT, class _Traits> |
| 940 | inline _LIBCPP_INLINE_VISIBILITY |
| 941 | basic_istream<_CharT, _Traits>& |
| 942 | basic_istream<_CharT, _Traits>::get(char_type& __c) |
| 943 | { |
| 944 | int_type __ch = get(); |
| 945 | if (__ch != traits_type::eof()) |
| 946 | __c = traits_type::to_char_type(__ch); |
| 947 | return *this; |
| 948 | } |
| 949 | |
| 950 | template<class _CharT, class _Traits> |
| 951 | basic_istream<_CharT, _Traits>& |
| 952 | basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm) |
| 953 | { |
| 954 | __gc_ = 0; |
| 955 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 956 | try |
| 957 | { |
| 958 | #endif |
| 959 | sentry __sen(*this, true); |
| 960 | if (__sen) |
| 961 | { |
| 962 | streamsize __c = 0; |
| 963 | if (__n > 0) |
| 964 | { |
| 965 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 966 | _I __i(*this); |
| 967 | _I __eof; |
| 968 | for (; __i != __eof && __n > 1; ++__i, ++__s, ++__c) |
| 969 | { |
| 970 | char_type __ch = *__i; |
| 971 | if (traits_type::eq(__ch, __dlm)) |
| 972 | break; |
| 973 | *__s = __ch; |
| 974 | } |
| 975 | *__s = char_type(); |
| 976 | ios_base::iostate __err = ios_base::goodbit; |
| 977 | if (__i == __eof) |
| 978 | __err |= ios_base::eofbit; |
| 979 | if (__c == 0) |
| 980 | __err |= ios_base::failbit; |
| 981 | this->setstate(__err); |
| 982 | } |
| 983 | else |
| 984 | this->setstate(ios_base::failbit); |
| 985 | __gc_ = __c; |
| 986 | } |
| 987 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 988 | } |
| 989 | catch (...) |
| 990 | { |
| 991 | this->__set_badbit_and_consider_rethrow(); |
| 992 | } |
| 993 | #endif |
| 994 | return *this; |
| 995 | } |
| 996 | |
| 997 | template<class _CharT, class _Traits> |
| 998 | inline _LIBCPP_INLINE_VISIBILITY |
| 999 | basic_istream<_CharT, _Traits>& |
| 1000 | basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n) |
| 1001 | { |
| 1002 | return get(__s, __n, this->widen('\n')); |
| 1003 | } |
| 1004 | |
| 1005 | template<class _CharT, class _Traits> |
| 1006 | basic_istream<_CharT, _Traits>& |
| 1007 | basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb, |
| 1008 | char_type __dlm) |
| 1009 | { |
| 1010 | __gc_ = 0; |
| 1011 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1012 | try |
| 1013 | { |
| 1014 | #endif |
| 1015 | sentry __sen(*this, true); |
| 1016 | if (__sen) |
| 1017 | { |
| 1018 | streamsize __c = 0; |
| 1019 | ios_base::iostate __err = ios_base::goodbit; |
| 1020 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1021 | try |
| 1022 | { |
| 1023 | #endif |
| 1024 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 1025 | typedef ostreambuf_iterator<char_type, traits_type> _O; |
| 1026 | _I __i(*this); |
| 1027 | _I __eof; |
| 1028 | _O __o(&__sb); |
| 1029 | for (; __i != __eof; ++__i, ++__o, ++__c) |
| 1030 | { |
| 1031 | char_type __ch = *__i; |
| 1032 | if (traits_type::eq(__ch, __dlm)) |
| 1033 | break; |
| 1034 | *__o = __ch; |
| 1035 | if (__o.failed()) |
| 1036 | break; |
| 1037 | } |
| 1038 | if (__i == __eof) |
| 1039 | __err |= ios_base::eofbit; |
| 1040 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1041 | } |
| 1042 | catch (...) |
| 1043 | { |
| 1044 | } |
| 1045 | #endif |
| 1046 | if (__c == 0) |
| 1047 | __err |= ios_base::failbit; |
| 1048 | this->setstate(__err); |
| 1049 | __gc_ = __c; |
| 1050 | } |
| 1051 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1052 | } |
| 1053 | catch (...) |
| 1054 | { |
| 1055 | this->__set_badbit_and_consider_rethrow(); |
| 1056 | } |
| 1057 | #endif |
| 1058 | return *this; |
| 1059 | } |
| 1060 | |
| 1061 | template<class _CharT, class _Traits> |
| 1062 | inline _LIBCPP_INLINE_VISIBILITY |
| 1063 | basic_istream<_CharT, _Traits>& |
| 1064 | basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb) |
| 1065 | { |
| 1066 | return get(__sb, this->widen('\n')); |
| 1067 | } |
| 1068 | |
| 1069 | template<class _CharT, class _Traits> |
| 1070 | basic_istream<_CharT, _Traits>& |
| 1071 | basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm) |
| 1072 | { |
| 1073 | __gc_ = 0; |
| 1074 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1075 | try |
| 1076 | { |
| 1077 | #endif |
| 1078 | sentry __sen(*this, true); |
| 1079 | if (__sen) |
| 1080 | { |
| 1081 | streamsize __c = 0; |
| 1082 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 1083 | _I __i(*this); |
| 1084 | _I __eof; |
| 1085 | for (; __i != __eof; ++__s, --__n) |
| 1086 | { |
| 1087 | char_type __ch = *__i; |
| 1088 | ++__i; |
| 1089 | ++__c; |
| 1090 | if (traits_type::eq(__ch, __dlm)) |
| 1091 | break; |
| 1092 | if (__n < 2) |
| 1093 | { |
| 1094 | this->setstate(ios_base::failbit); |
| 1095 | break; |
| 1096 | } |
| 1097 | *__s = __ch; |
| 1098 | } |
| 1099 | if (__n) |
| 1100 | *__s = char_type(); |
| 1101 | ios_base::iostate __err = ios_base::goodbit; |
| 1102 | if (__i == __eof) |
| 1103 | __err |= ios_base::eofbit; |
| 1104 | if (__c == 0) |
| 1105 | __err |= ios_base::failbit; |
| 1106 | this->setstate(__err); |
| 1107 | __gc_ = __c; |
| 1108 | } |
| 1109 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1110 | } |
| 1111 | catch (...) |
| 1112 | { |
| 1113 | this->__set_badbit_and_consider_rethrow(); |
| 1114 | } |
| 1115 | #endif |
| 1116 | return *this; |
| 1117 | } |
| 1118 | |
| 1119 | template<class _CharT, class _Traits> |
| 1120 | inline _LIBCPP_INLINE_VISIBILITY |
| 1121 | basic_istream<_CharT, _Traits>& |
| 1122 | basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n) |
| 1123 | { |
| 1124 | return getline(__s, __n, this->widen('\n')); |
| 1125 | } |
| 1126 | |
| 1127 | template<class _CharT, class _Traits> |
| 1128 | basic_istream<_CharT, _Traits>& |
| 1129 | basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm) |
| 1130 | { |
| 1131 | __gc_ = 0; |
| 1132 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1133 | try |
| 1134 | { |
| 1135 | #endif |
| 1136 | sentry __sen(*this, true); |
| 1137 | if (__sen) |
| 1138 | { |
| 1139 | streamsize __c = 0; |
| 1140 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 1141 | _I __i(*this); |
| 1142 | _I __eof; |
| 1143 | if (__n != numeric_limits<streamsize>::max()) |
| 1144 | { |
| 1145 | for (; __n > 0 && __i != __eof; --__n) |
| 1146 | { |
| 1147 | char_type __ch = *__i; |
| 1148 | ++__i; |
| 1149 | ++__c; |
| 1150 | if (traits_type::eq(__ch, __dlm)) |
| 1151 | break; |
| 1152 | } |
| 1153 | } |
| 1154 | else |
| 1155 | { |
| 1156 | while (__i != __eof) |
| 1157 | { |
| 1158 | char_type __ch = *__i; |
| 1159 | ++__i; |
| 1160 | ++__c; |
| 1161 | if (traits_type::eq(__ch, __dlm)) |
| 1162 | break; |
| 1163 | } |
| 1164 | } |
| 1165 | if (__i == __eof) |
| 1166 | this->setstate(ios_base::eofbit); |
| 1167 | __gc_ = __c; |
| 1168 | } |
| 1169 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1170 | } |
| 1171 | catch (...) |
| 1172 | { |
| 1173 | this->__set_badbit_and_consider_rethrow(); |
| 1174 | } |
| 1175 | #endif |
| 1176 | return *this; |
| 1177 | } |
| 1178 | |
| 1179 | template<class _CharT, class _Traits> |
| 1180 | typename basic_istream<_CharT, _Traits>::int_type |
| 1181 | basic_istream<_CharT, _Traits>::peek() |
| 1182 | { |
| 1183 | __gc_ = 0; |
| 1184 | int_type __r = traits_type::eof(); |
| 1185 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1186 | try |
| 1187 | { |
| 1188 | #endif |
| 1189 | sentry __sen(*this, true); |
| 1190 | if (__sen) |
| 1191 | __r = this->rdbuf()->sgetc(); |
| 1192 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1193 | } |
| 1194 | catch (...) |
| 1195 | { |
| 1196 | this->__set_badbit_and_consider_rethrow(); |
| 1197 | } |
| 1198 | #endif |
| 1199 | return __r; |
| 1200 | } |
| 1201 | |
| 1202 | template<class _CharT, class _Traits> |
| 1203 | basic_istream<_CharT, _Traits>& |
| 1204 | basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n) |
| 1205 | { |
| 1206 | __gc_ = 0; |
| 1207 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1208 | try |
| 1209 | { |
| 1210 | #endif |
| 1211 | sentry __sen(*this, true); |
| 1212 | if (__sen) |
| 1213 | { |
| 1214 | streamsize __c = 0; |
| 1215 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 1216 | _I __i(*this); |
| 1217 | _I __eof; |
| 1218 | for (; __i != __eof && __n > 0; ++__i, ++__s, ++__c, --__n) |
| 1219 | *__s = *__i; |
| 1220 | if (__i == __eof) |
| 1221 | { |
| 1222 | ios_base::iostate __err = ios_base::eofbit; |
| 1223 | if (__n > 0) |
| 1224 | __err |= ios_base::failbit; |
| 1225 | this->setstate(__err); |
| 1226 | } |
| 1227 | __gc_ = __c; |
| 1228 | } |
| 1229 | else |
| 1230 | this->setstate(ios_base::failbit); |
| 1231 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1232 | } |
| 1233 | catch (...) |
| 1234 | { |
| 1235 | this->__set_badbit_and_consider_rethrow(); |
| 1236 | } |
| 1237 | #endif |
| 1238 | return *this; |
| 1239 | } |
| 1240 | |
| 1241 | template<class _CharT, class _Traits> |
| 1242 | streamsize |
| 1243 | basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n) |
| 1244 | { |
| 1245 | __gc_ = 0; |
| 1246 | streamsize __c = 0; |
| 1247 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1248 | try |
| 1249 | { |
| 1250 | #endif |
| 1251 | sentry __sen(*this, true); |
| 1252 | if (__sen) |
| 1253 | { |
| 1254 | typedef istreambuf_iterator<char_type, traits_type> _I; |
| 1255 | _I __i(*this); |
| 1256 | _I __eof; |
| 1257 | __c = this->rdbuf()->in_avail(); |
| 1258 | switch (__c) |
| 1259 | { |
| 1260 | case -1: |
| 1261 | __i = __eof; |
| 1262 | break; |
| 1263 | case 0: |
| 1264 | break; |
| 1265 | default: |
| 1266 | __c = min(__c, __n); |
| 1267 | for (streamsize __k = 0; __k < __c; ++__k, ++__s, ++__i) |
| 1268 | *__s = *__i; |
| 1269 | } |
| 1270 | if (__i == __eof) |
| 1271 | this->setstate(ios_base::eofbit); |
| 1272 | __gc_ = __c; |
| 1273 | } |
| 1274 | else |
| 1275 | this->setstate(ios_base::failbit); |
| 1276 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1277 | } |
| 1278 | catch (...) |
| 1279 | { |
| 1280 | this->__set_badbit_and_consider_rethrow(); |
| 1281 | } |
| 1282 | #endif |
| 1283 | return __c; |
| 1284 | } |
| 1285 | |
| 1286 | template<class _CharT, class _Traits> |
| 1287 | basic_istream<_CharT, _Traits>& |
| 1288 | basic_istream<_CharT, _Traits>::putback(char_type __c) |
| 1289 | { |
| 1290 | __gc_ = 0; |
| 1291 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1292 | try |
| 1293 | { |
| 1294 | #endif |
| 1295 | sentry __sen(*this, true); |
| 1296 | if (__sen) |
| 1297 | { |
| 1298 | if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof()) |
| 1299 | this->setstate(ios_base::badbit); |
| 1300 | } |
| 1301 | else |
| 1302 | this->setstate(ios_base::failbit); |
| 1303 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1304 | } |
| 1305 | catch (...) |
| 1306 | { |
| 1307 | this->__set_badbit_and_consider_rethrow(); |
| 1308 | } |
| 1309 | #endif |
| 1310 | return *this; |
| 1311 | } |
| 1312 | |
| 1313 | template<class _CharT, class _Traits> |
| 1314 | basic_istream<_CharT, _Traits>& |
| 1315 | basic_istream<_CharT, _Traits>::unget() |
| 1316 | { |
| 1317 | __gc_ = 0; |
| 1318 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1319 | try |
| 1320 | { |
| 1321 | #endif |
| 1322 | sentry __sen(*this, true); |
| 1323 | if (__sen) |
| 1324 | { |
| 1325 | if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof()) |
| 1326 | this->setstate(ios_base::badbit); |
| 1327 | } |
| 1328 | else |
| 1329 | this->setstate(ios_base::failbit); |
| 1330 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1331 | } |
| 1332 | catch (...) |
| 1333 | { |
| 1334 | this->__set_badbit_and_consider_rethrow(); |
| 1335 | } |
| 1336 | #endif |
| 1337 | return *this; |
| 1338 | } |
| 1339 | |
| 1340 | template<class _CharT, class _Traits> |
| 1341 | int |
| 1342 | basic_istream<_CharT, _Traits>::sync() |
| 1343 | { |
| 1344 | int __r = 0; |
| 1345 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1346 | try |
| 1347 | { |
| 1348 | #endif |
| 1349 | sentry __sen(*this, true); |
| 1350 | if (__sen) |
| 1351 | { |
| 1352 | if (this->rdbuf() == 0) |
| 1353 | return -1; |
| 1354 | if (this->rdbuf()->pubsync() == -1) |
| 1355 | { |
| 1356 | this->setstate(ios_base::badbit); |
| 1357 | return -1; |
| 1358 | } |
| 1359 | } |
| 1360 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1361 | } |
| 1362 | catch (...) |
| 1363 | { |
| 1364 | this->__set_badbit_and_consider_rethrow(); |
| 1365 | } |
| 1366 | #endif |
| 1367 | return __r; |
| 1368 | } |
| 1369 | |
| 1370 | template<class _CharT, class _Traits> |
| 1371 | typename basic_istream<_CharT, _Traits>::pos_type |
| 1372 | basic_istream<_CharT, _Traits>::tellg() |
| 1373 | { |
| 1374 | pos_type __r(-1); |
| 1375 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1376 | try |
| 1377 | { |
| 1378 | #endif |
| 1379 | sentry __sen(*this, true); |
| 1380 | if (__sen) |
| 1381 | __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); |
| 1382 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1383 | } |
| 1384 | catch (...) |
| 1385 | { |
| 1386 | this->__set_badbit_and_consider_rethrow(); |
| 1387 | } |
| 1388 | #endif |
| 1389 | return __r; |
| 1390 | } |
| 1391 | |
| 1392 | template<class _CharT, class _Traits> |
| 1393 | basic_istream<_CharT, _Traits>& |
| 1394 | basic_istream<_CharT, _Traits>::seekg(pos_type __pos) |
| 1395 | { |
| 1396 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1397 | try |
| 1398 | { |
| 1399 | #endif |
| 1400 | sentry __sen(*this, true); |
| 1401 | if (__sen) |
| 1402 | if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) |
| 1403 | this->setstate(ios_base::failbit); |
| 1404 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1405 | } |
| 1406 | catch (...) |
| 1407 | { |
| 1408 | this->__set_badbit_and_consider_rethrow(); |
| 1409 | } |
| 1410 | #endif |
| 1411 | return *this; |
| 1412 | } |
| 1413 | |
| 1414 | template<class _CharT, class _Traits> |
| 1415 | basic_istream<_CharT, _Traits>& |
| 1416 | basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) |
| 1417 | { |
| 1418 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1419 | try |
| 1420 | { |
| 1421 | #endif |
| 1422 | sentry __sen(*this, true); |
| 1423 | if (__sen) |
| 1424 | this->rdbuf()->pubseekoff(__off, __dir, ios_base::in); |
| 1425 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1426 | } |
| 1427 | catch (...) |
| 1428 | { |
| 1429 | this->__set_badbit_and_consider_rethrow(); |
| 1430 | } |
| 1431 | #endif |
| 1432 | return *this; |
| 1433 | } |
| 1434 | |
| 1435 | template <class _CharT, class _Traits> |
| 1436 | basic_istream<_CharT, _Traits>& |
| 1437 | ws(basic_istream<_CharT, _Traits>& __is) |
| 1438 | { |
| 1439 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1440 | try |
| 1441 | { |
| 1442 | #endif |
| 1443 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); |
| 1444 | if (__sen) |
| 1445 | { |
| 1446 | typedef istreambuf_iterator<_CharT, _Traits> _I; |
| 1447 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
| 1448 | _I __i(__is); |
| 1449 | _I __eof; |
| 1450 | for (; __i != __eof; ++__i) |
| 1451 | if (!__ct.is(__ct.space, *__i)) |
| 1452 | break; |
| 1453 | if (__i == __eof) |
| 1454 | __is.setstate(ios_base::failbit | ios_base::eofbit); |
| 1455 | } |
| 1456 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1457 | } |
| 1458 | catch (...) |
| 1459 | { |
| 1460 | __is.__set_badbit_and_consider_rethrow(); |
| 1461 | } |
| 1462 | #endif |
| 1463 | return __is; |
| 1464 | } |
| 1465 | |
| 1466 | #ifdef _LIBCPP_MOVE |
| 1467 | |
| 1468 | template <class _CharT, class _Traits, class _Tp> |
| 1469 | inline _LIBCPP_INLINE_VISIBILITY |
| 1470 | basic_istream<_CharT, _Traits>& |
| 1471 | operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) |
| 1472 | { |
| 1473 | __is >> __x; |
| 1474 | return __is; |
| 1475 | } |
| 1476 | |
| 1477 | #endif |
| 1478 | |
| 1479 | template <class _CharT, class _Traits> |
| 1480 | class basic_iostream |
| 1481 | : public basic_istream<_CharT, _Traits>, |
| 1482 | public basic_ostream<_CharT, _Traits> |
| 1483 | { |
| 1484 | public: |
| 1485 | // types: |
| 1486 | typedef _CharT char_type; |
| 1487 | typedef _Traits traits_type; |
| 1488 | typedef typename traits_type::int_type int_type; |
| 1489 | typedef typename traits_type::pos_type pos_type; |
| 1490 | typedef typename traits_type::off_type off_type; |
| 1491 | |
| 1492 | // constructor/destructor |
| 1493 | explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb); |
| 1494 | virtual ~basic_iostream(); |
| 1495 | protected: |
| 1496 | #ifdef _LIBCPP_MOVE |
| 1497 | basic_iostream(basic_iostream&& __rhs); |
| 1498 | #endif |
| 1499 | |
| 1500 | // assign/swap |
| 1501 | #ifdef _LIBCPP_MOVE |
| 1502 | basic_iostream& operator=(basic_iostream&& __rhs); |
| 1503 | #endif |
| 1504 | void swap(basic_iostream& __rhs); |
| 1505 | public: |
| 1506 | }; |
| 1507 | |
| 1508 | template <class _CharT, class _Traits> |
| 1509 | inline _LIBCPP_INLINE_VISIBILITY |
| 1510 | basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf<char_type, traits_type>* __sb) |
| 1511 | : basic_istream<_CharT, _Traits>(__sb) |
| 1512 | { |
| 1513 | } |
| 1514 | |
| 1515 | #ifdef _LIBCPP_MOVE |
| 1516 | |
| 1517 | template <class _CharT, class _Traits> |
| 1518 | inline _LIBCPP_INLINE_VISIBILITY |
| 1519 | basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs) |
| 1520 | : basic_istream<_CharT, _Traits>(_STD::move(__rhs)) |
| 1521 | { |
| 1522 | } |
| 1523 | |
| 1524 | template <class _CharT, class _Traits> |
| 1525 | inline _LIBCPP_INLINE_VISIBILITY |
| 1526 | basic_iostream<_CharT, _Traits>& |
| 1527 | basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs) |
| 1528 | { |
| 1529 | swap(__rhs); |
| 1530 | return *this; |
| 1531 | } |
| 1532 | |
| 1533 | #endif |
| 1534 | |
| 1535 | template <class _CharT, class _Traits> |
| 1536 | basic_iostream<_CharT, _Traits>::~basic_iostream() |
| 1537 | { |
| 1538 | } |
| 1539 | |
| 1540 | template <class _CharT, class _Traits> |
| 1541 | inline _LIBCPP_INLINE_VISIBILITY |
| 1542 | void |
| 1543 | basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs) |
| 1544 | { |
| 1545 | basic_istream<char_type, traits_type>::swap(__rhs); |
| 1546 | } |
| 1547 | |
| 1548 | template<class _CharT, class _Traits, class _Allocator> |
| 1549 | basic_istream<_CharT, _Traits>& |
| 1550 | operator>>(basic_istream<_CharT, _Traits>& __is, |
| 1551 | basic_string<_CharT, _Traits, _Allocator>& __str) |
| 1552 | { |
| 1553 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1554 | try |
| 1555 | { |
| 1556 | #endif |
| 1557 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 1558 | if (__sen) |
| 1559 | { |
| 1560 | __str.clear(); |
| 1561 | typedef istreambuf_iterator<_CharT, _Traits> _I; |
| 1562 | streamsize __n = __is.width(); |
| 1563 | if (__n == 0) |
| 1564 | __n = __str.max_size(); |
| 1565 | if (__n < 0) |
| 1566 | __n = numeric_limits<streamsize>::max(); |
| 1567 | streamsize __c = 0; |
| 1568 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
| 1569 | _I __i(__is); |
| 1570 | _I __eof; |
| 1571 | for (; __i != __eof && __c < __n; ++__i, ++__c) |
| 1572 | { |
| 1573 | _CharT __ch = *__i; |
| 1574 | if (__ct.is(__ct.space, __ch)) |
| 1575 | break; |
| 1576 | __str.push_back(__ch); |
| 1577 | } |
| 1578 | __is.width(0); |
| 1579 | ios_base::iostate __err = ios_base::goodbit; |
| 1580 | if (__i == __eof) |
| 1581 | __err |= ios_base::eofbit; |
| 1582 | if (__c == 0) |
| 1583 | __err |= ios_base::failbit; |
| 1584 | __is.setstate(__err); |
| 1585 | } |
| 1586 | else |
| 1587 | __is.setstate(ios_base::failbit); |
| 1588 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1589 | } |
| 1590 | catch (...) |
| 1591 | { |
| 1592 | __is.__set_badbit_and_consider_rethrow(); |
| 1593 | } |
| 1594 | #endif |
| 1595 | return __is; |
| 1596 | } |
| 1597 | |
| 1598 | template<class _CharT, class _Traits, class _Allocator> |
| 1599 | basic_istream<_CharT, _Traits>& |
| 1600 | getline(basic_istream<_CharT, _Traits>& __is, |
| 1601 | basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) |
| 1602 | { |
| 1603 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1604 | try |
| 1605 | { |
| 1606 | #endif |
| 1607 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); |
| 1608 | if (__sen) |
| 1609 | { |
| 1610 | __str.clear(); |
| 1611 | streamsize __c = 0; |
| 1612 | typedef istreambuf_iterator<_CharT, _Traits> _I; |
| 1613 | _I __i(__is); |
| 1614 | _I __eof; |
| 1615 | streamsize __n = __str.max_size(); |
| 1616 | if (__n < 0) |
| 1617 | __n = numeric_limits<streamsize>::max(); |
| 1618 | for (; __i != __eof;) |
| 1619 | { |
| 1620 | _CharT __ch = *__i; |
| 1621 | ++__i; |
| 1622 | ++__c; |
| 1623 | if (_Traits::eq(__ch, __dlm)) |
| 1624 | break; |
| 1625 | if (__c == __n) |
| 1626 | { |
| 1627 | __is.setstate(ios_base::failbit); |
| 1628 | break; |
| 1629 | } |
| 1630 | __str.push_back(__ch); |
| 1631 | } |
| 1632 | ios_base::iostate __err = ios_base::goodbit; |
| 1633 | if (__i == __eof) |
| 1634 | __err |= ios_base::eofbit; |
| 1635 | if (__c == 0) |
| 1636 | __err |= ios_base::failbit; |
| 1637 | __is.setstate(__err); |
| 1638 | } |
| 1639 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1640 | } |
| 1641 | catch (...) |
| 1642 | { |
| 1643 | __is.__set_badbit_and_consider_rethrow(); |
| 1644 | } |
| 1645 | #endif |
| 1646 | return __is; |
| 1647 | } |
| 1648 | |
| 1649 | template<class _CharT, class _Traits, class _Allocator> |
| 1650 | inline |
| 1651 | basic_istream<_CharT, _Traits>& |
| 1652 | getline(basic_istream<_CharT, _Traits>& __is, |
| 1653 | basic_string<_CharT, _Traits, _Allocator>& __str) |
| 1654 | { |
| 1655 | return getline(__is, __str, __is.widen('\n')); |
| 1656 | } |
| 1657 | |
| 1658 | #ifdef _LIBCPP_MOVE |
| 1659 | |
| 1660 | template<class _CharT, class _Traits, class _Allocator> |
| 1661 | inline |
| 1662 | basic_istream<_CharT, _Traits>& |
| 1663 | getline(basic_istream<_CharT, _Traits>&& __is, |
| 1664 | basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) |
| 1665 | { |
| 1666 | return getline(__is, __str, __dlm); |
| 1667 | } |
| 1668 | |
| 1669 | template<class _CharT, class _Traits, class _Allocator> |
| 1670 | inline |
| 1671 | basic_istream<_CharT, _Traits>& |
| 1672 | getline(basic_istream<_CharT, _Traits>&& __is, |
| 1673 | basic_string<_CharT, _Traits, _Allocator>& __str) |
| 1674 | { |
| 1675 | return getline(__is, __str, __is.widen('\n')); |
| 1676 | } |
| 1677 | |
| 1678 | #endif |
| 1679 | |
| 1680 | template <class _CharT, class _Traits, size_t _Size> |
| 1681 | basic_istream<_CharT, _Traits>& |
| 1682 | operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) |
| 1683 | { |
| 1684 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1685 | try |
| 1686 | { |
| 1687 | #endif |
| 1688 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 1689 | if (__sen) |
| 1690 | { |
| 1691 | basic_string<_CharT, _Traits> __str; |
| 1692 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
| 1693 | typedef istreambuf_iterator<_CharT, _Traits> _I; |
| 1694 | streamsize __c = 0; |
| 1695 | _CharT __zero = __ct.widen('0'); |
| 1696 | _CharT __one = __ct.widen('1'); |
| 1697 | _I __i(__is); |
| 1698 | _I __eof; |
| 1699 | for (; __i != __eof && __c < _Size; ++__i, ++__c) |
| 1700 | { |
| 1701 | _CharT __ch = *__i; |
| 1702 | if (__ch != __zero && __ch != __one) |
| 1703 | break; |
| 1704 | __str.push_back(__ch); |
| 1705 | } |
| 1706 | __is.width(0); |
| 1707 | __x = bitset<_Size>(__str); |
| 1708 | ios_base::iostate __err = ios_base::goodbit; |
| 1709 | if (__i == __eof) |
| 1710 | __err |= ios_base::eofbit; |
| 1711 | if (__c == 0) |
| 1712 | __err |= ios_base::failbit; |
| 1713 | __is.setstate(__err); |
| 1714 | } |
| 1715 | else |
| 1716 | __is.setstate(ios_base::failbit); |
| 1717 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1718 | } |
| 1719 | catch (...) |
| 1720 | { |
| 1721 | __is.__set_badbit_and_consider_rethrow(); |
| 1722 | } |
| 1723 | #endif |
| 1724 | return __is; |
| 1725 | } |
| 1726 | |
| 1727 | extern template class basic_istream<char>; |
| 1728 | extern template class basic_istream<wchar_t>; |
| 1729 | extern template class basic_iostream<char>; |
| 1730 | |
| 1731 | _LIBCPP_END_NAMESPACE_STD |
| 1732 | |
| 1733 | #endif // _LIBCPP_ISTREAM |