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