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