blob: b427605d23b986ce24245c274d00853d4b446d7c [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- istream ----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_ISTREAM
12#define _LIBCPP_ISTREAM
13
14/*
15 istream synopsis
16
17template <class charT, class traits = char_traits<charT> >
18class basic_istream
19 : virtual public basic_ios<charT,traits>
20{
21public:
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:
88template<class charT, class traits>
89 basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT&);
90
91template<class traits>
92 basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char&);
93
94template<class traits>
95 basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char&);
96
97template<class charT, class traits>
98 basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT*);
99
100template<class traits>
101 basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char*);
102
103template<class traits>
104 basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char*);
105
106template <class charT, class traits>
107 void
108 swap(basic_istream<charT, traits>& x, basic_istream<charT, traits>& y);
109
110typedef basic_istream<char> istream;
111typedef basic_istream<wchar_t> wistream;
112
113template <class charT, class traits = char_traits<charT> >
114class basic_iostream :
115 public basic_istream<charT,traits>,
116 public basic_ostream<charT,traits>
117{
118public:
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
136template <class charT, class traits>
137 void
138 swap(basic_iostream<charT, traits>& x, basic_iostream<charT, traits>& y);
139
140typedef basic_iostream<char> iostream;
141typedef basic_iostream<wchar_t> wiostream;
142
143template <class charT, class traits>
144 basic_istream<charT,traits>&
145 ws(basic_istream<charT,traits>& is);
146
147template <class charT, class traits, class T>
148 basic_istream<charT, traits>&
149 operator>>(basic_istream<charT, traits>&& is, T& x);
150
151} // std
152
153*/
154
155#include <__config>
156#include <ostream>
157
158#pragma GCC system_header
159
160_LIBCPP_BEGIN_NAMESPACE_STD
161
162template <class _CharT, class _Traits>
Howard Hinnant68a8e902010-09-22 15:29:08 +0000163class _LIBCPP_VISIBLE basic_istream
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000164 : virtual public basic_ios<_CharT, _Traits>
165{
166 streamsize __gc_;
167public:
168 // types (inherited from basic_ios (27.5.4)):
169 typedef _CharT char_type;
170 typedef _Traits traits_type;
171 typedef typename traits_type::int_type int_type;
172 typedef typename traits_type::pos_type pos_type;
173 typedef typename traits_type::off_type off_type;
174
175 // 27.7.1.1.1 Constructor/destructor:
176 explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb);
177 virtual ~basic_istream();
178protected:
Howard Hinnant73d21a42010-09-04 23:28:19 +0000179#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000180 basic_istream(basic_istream&& __rhs);
181#endif
182
183 // 27.7.1.1.2 Assign/swap:
Howard Hinnant73d21a42010-09-04 23:28:19 +0000184#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000185 basic_istream& operator=(basic_istream&& __rhs);
186#endif
187 void swap(basic_istream& __rhs);
188public:
189
190 // 27.7.1.1.3 Prefix/suffix:
191 class sentry;
192
193 // 27.7.1.2 Formatted input:
194 basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&));
195 basic_istream& operator>>(basic_ios<char_type, traits_type>&
196 (*__pf)(basic_ios<char_type, traits_type>&));
197 basic_istream& operator>>(ios_base& (*__pf)(ios_base&));
198 basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb);
199 basic_istream& operator>>(bool& __n);
200 basic_istream& operator>>(short& __n);
201 basic_istream& operator>>(unsigned short& __n);
202 basic_istream& operator>>(int& __n);
203 basic_istream& operator>>(unsigned int& __n);
204 basic_istream& operator>>(long& __n);
205 basic_istream& operator>>(unsigned long& __n);
206 basic_istream& operator>>(long long& __n);
207 basic_istream& operator>>(unsigned long long& __n);
208 basic_istream& operator>>(float& __f);
209 basic_istream& operator>>(double& __f);
210 basic_istream& operator>>(long double& __f);
211 basic_istream& operator>>(void*& __p);
212
213 // 27.7.1.3 Unformatted input:
Howard Hinnant68a8e902010-09-22 15:29:08 +0000214 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000215 streamsize gcount() const {return __gc_;}
216 int_type get();
217 basic_istream& get(char_type& __c);
218 basic_istream& get(char_type* __s, streamsize __n);
219 basic_istream& get(char_type* __s, streamsize __n, char_type __dlm);
220 basic_istream& get(basic_streambuf<char_type, traits_type>& __sb);
221 basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm);
222
223 basic_istream& getline(char_type* __s, streamsize __n);
224 basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
225
226 basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
227 int_type peek();
228 basic_istream& read (char_type* __s, streamsize __n);
229 streamsize readsome(char_type* __s, streamsize __n);
230
231 basic_istream& putback(char_type __c);
232 basic_istream& unget();
233 int sync();
234
235 pos_type tellg();
236 basic_istream& seekg(pos_type __pos);
237 basic_istream& seekg(off_type __off, ios_base::seekdir __dir);
238};
239
240template <class _CharT, class _Traits>
Howard Hinnant68a8e902010-09-22 15:29:08 +0000241class _LIBCPP_VISIBLE basic_istream<_CharT, _Traits>::sentry
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000242{
243 bool __ok_;
244
245 sentry(const sentry&); // = delete;
246 sentry& operator=(const sentry&); // = delete;
247
248public:
249 explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
250// ~sentry() = default;
251
Howard Hinnant68a8e902010-09-22 15:29:08 +0000252 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000253 // explicit
254 operator bool() const {return __ok_;}
255};
256
257template <class _CharT, class _Traits>
258basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is,
259 bool __noskipws)
260 : __ok_(false)
261{
262 if (__is.good())
263 {
264 if (__is.tie())
265 __is.tie()->flush();
266 if (!__noskipws && (__is.flags() & ios_base::skipws))
267 {
268 typedef istreambuf_iterator<_CharT, _Traits> _I;
269 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
270 _I __i(__is);
271 _I __eof;
272 for (; __i != __eof; ++__i)
273 if (!__ct.is(__ct.space, *__i))
274 break;
275 if (__i == __eof)
276 __is.setstate(ios_base::failbit | ios_base::eofbit);
277 }
278 __ok_ = __is.good();
279 }
280 else
281 __is.setstate(ios_base::failbit);
282}
283
284template <class _CharT, class _Traits>
285inline _LIBCPP_INLINE_VISIBILITY
286basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf<char_type, traits_type>* __sb)
287 : __gc_(0)
288{
289 this->init(__sb);
290}
291
Howard Hinnant73d21a42010-09-04 23:28:19 +0000292#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000293
294template <class _CharT, class _Traits>
295inline _LIBCPP_INLINE_VISIBILITY
296basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
297 : __gc_(__rhs.__gc_)
298{
299 __rhs.__gc_ = 0;
300 this->move(__rhs);
301}
302
303template <class _CharT, class _Traits>
304inline _LIBCPP_INLINE_VISIBILITY
305basic_istream<_CharT, _Traits>&
306basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
307{
308 swap(__rhs);
309 return *this;
310}
311
Howard Hinnant73d21a42010-09-04 23:28:19 +0000312#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000313
314template <class _CharT, class _Traits>
315basic_istream<_CharT, _Traits>::~basic_istream()
316{
317}
318
319template <class _CharT, class _Traits>
320inline _LIBCPP_INLINE_VISIBILITY
321void
322basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
323{
324 _STD::swap(__gc_, __rhs.__gc_);
325 basic_ios<char_type, traits_type>::swap(__rhs);
326}
327
328template <class _CharT, class _Traits>
329basic_istream<_CharT, _Traits>&
330basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
331{
332#ifndef _LIBCPP_NO_EXCEPTIONS
333 try
334 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000335#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000336 sentry __s(*this);
337 if (__s)
338 {
339 typedef istreambuf_iterator<char_type, traits_type> _I;
340 typedef num_get<char_type, _I> _F;
341 ios_base::iostate __err = ios_base::goodbit;
342 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
343 this->setstate(__err);
344 }
345#ifndef _LIBCPP_NO_EXCEPTIONS
346 }
347 catch (...)
348 {
349 this->__set_badbit_and_consider_rethrow();
350 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000351#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000352 return *this;
353}
354
355template <class _CharT, class _Traits>
356basic_istream<_CharT, _Traits>&
357basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n)
358{
359#ifndef _LIBCPP_NO_EXCEPTIONS
360 try
361 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000362#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000363 sentry __s(*this);
364 if (__s)
365 {
366 typedef istreambuf_iterator<char_type, traits_type> _I;
367 typedef num_get<char_type, _I> _F;
368 ios_base::iostate __err = ios_base::goodbit;
369 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
370 this->setstate(__err);
371 }
372#ifndef _LIBCPP_NO_EXCEPTIONS
373 }
374 catch (...)
375 {
376 this->__set_badbit_and_consider_rethrow();
377 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000378#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000379 return *this;
380}
381
382template <class _CharT, class _Traits>
383basic_istream<_CharT, _Traits>&
384basic_istream<_CharT, _Traits>::operator>>(long& __n)
385{
386#ifndef _LIBCPP_NO_EXCEPTIONS
387 try
388 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000389#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000390 sentry __s(*this);
391 if (__s)
392 {
393 typedef istreambuf_iterator<char_type, traits_type> _I;
394 typedef num_get<char_type, _I> _F;
395 ios_base::iostate __err = ios_base::goodbit;
396 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
397 this->setstate(__err);
398 }
399#ifndef _LIBCPP_NO_EXCEPTIONS
400 }
401 catch (...)
402 {
403 this->__set_badbit_and_consider_rethrow();
404 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000405#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000406 return *this;
407}
408
409template <class _CharT, class _Traits>
410basic_istream<_CharT, _Traits>&
411basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n)
412{
413#ifndef _LIBCPP_NO_EXCEPTIONS
414 try
415 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000416#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000417 sentry __s(*this);
418 if (__s)
419 {
420 typedef istreambuf_iterator<char_type, traits_type> _I;
421 typedef num_get<char_type, _I> _F;
422 ios_base::iostate __err = ios_base::goodbit;
423 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
424 this->setstate(__err);
425 }
426#ifndef _LIBCPP_NO_EXCEPTIONS
427 }
428 catch (...)
429 {
430 this->__set_badbit_and_consider_rethrow();
431 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000432#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000433 return *this;
434}
435
436template <class _CharT, class _Traits>
437basic_istream<_CharT, _Traits>&
438basic_istream<_CharT, _Traits>::operator>>(long long& __n)
439{
440#ifndef _LIBCPP_NO_EXCEPTIONS
441 try
442 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000443#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000444 sentry __s(*this);
445 if (__s)
446 {
447 typedef istreambuf_iterator<char_type, traits_type> _I;
448 typedef num_get<char_type, _I> _F;
449 ios_base::iostate __err = ios_base::goodbit;
450 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
451 this->setstate(__err);
452 }
453#ifndef _LIBCPP_NO_EXCEPTIONS
454 }
455 catch (...)
456 {
457 this->__set_badbit_and_consider_rethrow();
458 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000459#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000460 return *this;
461}
462
463template <class _CharT, class _Traits>
464basic_istream<_CharT, _Traits>&
465basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n)
466{
467#ifndef _LIBCPP_NO_EXCEPTIONS
468 try
469 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000470#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000471 sentry __s(*this);
472 if (__s)
473 {
474 typedef istreambuf_iterator<char_type, traits_type> _I;
475 typedef num_get<char_type, _I> _F;
476 ios_base::iostate __err = ios_base::goodbit;
477 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
478 this->setstate(__err);
479 }
480#ifndef _LIBCPP_NO_EXCEPTIONS
481 }
482 catch (...)
483 {
484 this->__set_badbit_and_consider_rethrow();
485 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000486#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000487 return *this;
488}
489
490template <class _CharT, class _Traits>
491basic_istream<_CharT, _Traits>&
492basic_istream<_CharT, _Traits>::operator>>(float& __n)
493{
494#ifndef _LIBCPP_NO_EXCEPTIONS
495 try
496 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000497#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000498 sentry __s(*this);
499 if (__s)
500 {
501 typedef istreambuf_iterator<char_type, traits_type> _I;
502 typedef num_get<char_type, _I> _F;
503 ios_base::iostate __err = ios_base::goodbit;
504 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
505 this->setstate(__err);
506 }
507#ifndef _LIBCPP_NO_EXCEPTIONS
508 }
509 catch (...)
510 {
511 this->__set_badbit_and_consider_rethrow();
512 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000513#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000514 return *this;
515}
516
517template <class _CharT, class _Traits>
518basic_istream<_CharT, _Traits>&
519basic_istream<_CharT, _Traits>::operator>>(double& __n)
520{
521#ifndef _LIBCPP_NO_EXCEPTIONS
522 try
523 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000524#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000525 sentry __s(*this);
526 if (__s)
527 {
528 typedef istreambuf_iterator<char_type, traits_type> _I;
529 typedef num_get<char_type, _I> _F;
530 ios_base::iostate __err = ios_base::goodbit;
531 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
532 this->setstate(__err);
533 }
534#ifndef _LIBCPP_NO_EXCEPTIONS
535 }
536 catch (...)
537 {
538 this->__set_badbit_and_consider_rethrow();
539 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000540#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000541 return *this;
542}
543
544template <class _CharT, class _Traits>
545basic_istream<_CharT, _Traits>&
546basic_istream<_CharT, _Traits>::operator>>(long double& __n)
547{
548#ifndef _LIBCPP_NO_EXCEPTIONS
549 try
550 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000551#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000552 sentry __s(*this);
553 if (__s)
554 {
555 typedef istreambuf_iterator<char_type, traits_type> _I;
556 typedef num_get<char_type, _I> _F;
557 ios_base::iostate __err = ios_base::goodbit;
558 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
559 this->setstate(__err);
560 }
561#ifndef _LIBCPP_NO_EXCEPTIONS
562 }
563 catch (...)
564 {
565 this->__set_badbit_and_consider_rethrow();
566 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000567#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000568 return *this;
569}
570
571template <class _CharT, class _Traits>
572basic_istream<_CharT, _Traits>&
573basic_istream<_CharT, _Traits>::operator>>(bool& __n)
574{
575#ifndef _LIBCPP_NO_EXCEPTIONS
576 try
577 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000578#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000579 sentry __s(*this);
580 if (__s)
581 {
582 typedef istreambuf_iterator<char_type, traits_type> _I;
583 typedef num_get<char_type, _I> _F;
584 ios_base::iostate __err = ios_base::goodbit;
585 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
586 this->setstate(__err);
587 }
588#ifndef _LIBCPP_NO_EXCEPTIONS
589 }
590 catch (...)
591 {
592 this->__set_badbit_and_consider_rethrow();
593 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000594#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000595 return *this;
596}
597
598template <class _CharT, class _Traits>
599basic_istream<_CharT, _Traits>&
600basic_istream<_CharT, _Traits>::operator>>(void*& __n)
601{
602#ifndef _LIBCPP_NO_EXCEPTIONS
603 try
604 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000605#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000606 sentry __s(*this);
607 if (__s)
608 {
609 typedef istreambuf_iterator<char_type, traits_type> _I;
610 typedef num_get<char_type, _I> _F;
611 ios_base::iostate __err = ios_base::goodbit;
612 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __n);
613 this->setstate(__err);
614 }
615#ifndef _LIBCPP_NO_EXCEPTIONS
616 }
617 catch (...)
618 {
619 this->__set_badbit_and_consider_rethrow();
620 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000621#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000622 return *this;
623}
624
625template <class _CharT, class _Traits>
626basic_istream<_CharT, _Traits>&
627basic_istream<_CharT, _Traits>::operator>>(short& __n)
628{
629#ifndef _LIBCPP_NO_EXCEPTIONS
630 try
631 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000632#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000633 sentry __s(*this);
634 if (__s)
635 {
636 typedef istreambuf_iterator<char_type, traits_type> _I;
637 typedef num_get<char_type, _I> _F;
638 ios_base::iostate __err = ios_base::goodbit;
639 long __temp;
640 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __temp);
641 if (__temp < numeric_limits<short>::min())
642 {
643 __err |= ios_base::failbit;
644 __n = numeric_limits<short>::min();
645 }
646 else if (__temp > numeric_limits<short>::max())
647 {
648 __err |= ios_base::failbit;
649 __n = numeric_limits<short>::max();
650 }
651 else
652 __n = static_cast<short>(__temp);
653 this->setstate(__err);
654 }
655#ifndef _LIBCPP_NO_EXCEPTIONS
656 }
657 catch (...)
658 {
659 this->__set_badbit_and_consider_rethrow();
660 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000661#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000662 return *this;
663}
664
665template <class _CharT, class _Traits>
666basic_istream<_CharT, _Traits>&
667basic_istream<_CharT, _Traits>::operator>>(int& __n)
668{
669#ifndef _LIBCPP_NO_EXCEPTIONS
670 try
671 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000672#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000673 sentry __s(*this);
674 if (__s)
675 {
676 typedef istreambuf_iterator<char_type, traits_type> _I;
677 typedef num_get<char_type, _I> _F;
678 ios_base::iostate __err = ios_base::goodbit;
679 long __temp;
680 use_facet<_F>(this->getloc()).get(_I(*this), _I(), *this, __err, __temp);
681 if (__temp < numeric_limits<int>::min())
682 {
683 __err |= ios_base::failbit;
684 __n = numeric_limits<int>::min();
685 }
686 else if (__temp > numeric_limits<int>::max())
687 {
688 __err |= ios_base::failbit;
689 __n = numeric_limits<int>::max();
690 }
691 else
692 __n = static_cast<int>(__temp);
693 this->setstate(__err);
694 }
695#ifndef _LIBCPP_NO_EXCEPTIONS
696 }
697 catch (...)
698 {
699 this->__set_badbit_and_consider_rethrow();
700 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000701#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000702 return *this;
703}
704
705template <class _CharT, class _Traits>
706inline _LIBCPP_INLINE_VISIBILITY
707basic_istream<_CharT, _Traits>&
708basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&))
709{
710 return __pf(*this);
711}
712
713template <class _CharT, class _Traits>
714inline _LIBCPP_INLINE_VISIBILITY
715basic_istream<_CharT, _Traits>&
716basic_istream<_CharT, _Traits>::operator>>(basic_ios<char_type, traits_type>&
717 (*__pf)(basic_ios<char_type, traits_type>&))
718{
719 __pf(*this);
720 return *this;
721}
722
723template <class _CharT, class _Traits>
724inline _LIBCPP_INLINE_VISIBILITY
725basic_istream<_CharT, _Traits>&
726basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
727{
728 __pf(*this);
729 return *this;
730}
731
732template<class _CharT, class _Traits>
733basic_istream<_CharT, _Traits>&
734operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s)
735{
736#ifndef _LIBCPP_NO_EXCEPTIONS
737 try
738 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000739#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000740 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
741 if (__sen)
742 {
743 typedef istreambuf_iterator<_CharT, _Traits> _I;
744 streamsize __n = __is.width();
745 if (__n == 0)
746 __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1;
747 streamsize __c = 0;
748 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
749 _I __i(__is);
750 _I __eof;
751 for (; __i != __eof && __c < __n-1; ++__i, ++__s, ++__c)
752 {
753 _CharT __ch = *__i;
754 if (__ct.is(__ct.space, __ch))
755 break;
756 *__s = __ch;
757 }
758 *__s = _CharT();
759 __is.width(0);
760 ios_base::iostate __err = ios_base::goodbit;
761 if (__i == __eof)
762 __err |= ios_base::eofbit;
763 if (__c == 0)
764 __err |= ios_base::failbit;
765 __is.setstate(__err);
766 }
767#ifndef _LIBCPP_NO_EXCEPTIONS
768 }
769 catch (...)
770 {
771 __is.__set_badbit_and_consider_rethrow();
772 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000773#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000774 return __is;
775}
776
777template<class _Traits>
778inline _LIBCPP_INLINE_VISIBILITY
779basic_istream<char, _Traits>&
780operator>>(basic_istream<char, _Traits>& __is, unsigned char* __s)
781{
782 return __is >> (char*)__s;
783}
784
785template<class _Traits>
786inline _LIBCPP_INLINE_VISIBILITY
787basic_istream<char, _Traits>&
788operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
789{
790 return __is >> (char*)__s;
791}
792
793template<class _CharT, class _Traits>
794basic_istream<_CharT, _Traits>&
795operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
796{
797#ifndef _LIBCPP_NO_EXCEPTIONS
798 try
799 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000800#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000801 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
802 if (__sen)
803 {
Howard Hinnantdf85e572011-02-27 18:02:02 +0000804#if 1
805 typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
806 if (_Traits::eq_int_type(__i, _Traits::eof()))
807 __is.setstate(ios_base::eofbit | ios_base::failbit);
808 else
809 __c = _Traits::to_char_type(__i);
810#else
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000811 typedef istreambuf_iterator<_CharT, _Traits> _I;
812 _I __i(__is);
813 _I __eof;
814 if (__i != __eof)
815 {
816 __c = *__i;
817 if (++__i == __eof)
818 __is.setstate(ios_base::eofbit);
819 }
820 else
821 __is.setstate(ios_base::eofbit | ios_base::failbit);
Howard Hinnantdf85e572011-02-27 18:02:02 +0000822#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000823 }
824#ifndef _LIBCPP_NO_EXCEPTIONS
825 }
826 catch (...)
827 {
828 __is.__set_badbit_and_consider_rethrow();
829 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000830#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000831 return __is;
832}
833
834template<class _Traits>
835inline _LIBCPP_INLINE_VISIBILITY
836basic_istream<char, _Traits>&
837operator>>(basic_istream<char, _Traits>& __is, unsigned char& __c)
838{
839 return __is >> (char&)__c;
840}
841
842template<class _Traits>
843inline _LIBCPP_INLINE_VISIBILITY
844basic_istream<char, _Traits>&
845operator>>(basic_istream<char, _Traits>& __is, signed char& __c)
846{
847 return __is >> (char&)__c;
848}
849
850template<class _CharT, class _Traits>
851basic_istream<_CharT, _Traits>&
852basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb)
853{
854 __gc_ = 0;
855#ifndef _LIBCPP_NO_EXCEPTIONS
856 try
857 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000858#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000859 sentry __s(*this, true);
860 if (__s)
861 {
862 streamsize __c = 0;
863 if (__sb)
864 {
865#ifndef _LIBCPP_NO_EXCEPTIONS
866 try
867 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000868#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000869 typedef istreambuf_iterator<char_type, traits_type> _I;
870 typedef ostreambuf_iterator<char_type, traits_type> _O;
871 _I __i(*this);
872 _I __eof;
873 _O __o(__sb);
874 for (; __i != __eof; ++__i, ++__o, ++__c)
875 {
876 *__o = *__i;
877 if (__o.failed())
878 break;
879 }
880 ios_base::iostate __err = ios_base::goodbit;
881 if (__i == __eof)
882 __err |= ios_base::eofbit;
883 if (__c == 0)
884 __err |= ios_base::failbit;
885 this->setstate(__err);
886#ifndef _LIBCPP_NO_EXCEPTIONS
887 }
888 catch (...)
889 {
890 if (__c == 0)
891 this->__set_failbit_and_consider_rethrow();
892 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000893#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000894 }
895 else
896 this->setstate(ios_base::failbit);
897 __gc_ = __c;
898 }
899#ifndef _LIBCPP_NO_EXCEPTIONS
900 }
901 catch (...)
902 {
903 this->__set_badbit_and_consider_rethrow();
904 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000905#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000906 return *this;
907}
908
909template<class _CharT, class _Traits>
910typename basic_istream<_CharT, _Traits>::int_type
911basic_istream<_CharT, _Traits>::get()
912{
913 __gc_ = 0;
914 int_type __r = traits_type::eof();
915#ifndef _LIBCPP_NO_EXCEPTIONS
916 try
917 {
Howard Hinnant324bb032010-08-22 00:02:43 +0000918#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000919 sentry __s(*this, true);
920 if (__s)
921 {
922 streamsize __c = 0;
923 typedef istreambuf_iterator<char_type, traits_type> _I;
924 _I __i(*this);
925 _I __eof;
926 ios_base::iostate __err = ios_base::goodbit;
927 if (__i != __eof)
928 {
929 __r = traits_type::to_int_type(*__i);
930 ++__c;
931 if (++__i == __eof)
932 __err |= ios_base::eofbit;
933 }
934 else
935 __err |= ios_base::failbit | ios_base::eofbit;
936 this->setstate(__err);
937 __gc_ = __c;
938 }
939#ifndef _LIBCPP_NO_EXCEPTIONS
940 }
941 catch (...)
942 {
943 this->__set_badbit_and_consider_rethrow();
944 }
Howard Hinnant324bb032010-08-22 00:02:43 +0000945#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000946 return __r;
947}
948
949template<class _CharT, class _Traits>
950inline _LIBCPP_INLINE_VISIBILITY
951basic_istream<_CharT, _Traits>&
952basic_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
960template<class _CharT, class _Traits>
961basic_istream<_CharT, _Traits>&
962basic_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 Hinnant324bb032010-08-22 00:02:43 +0000968#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000969 sentry __sen(*this, true);
970 if (__sen)
971 {
972 streamsize __c = 0;
973 if (__n > 0)
974 {
975 typedef istreambuf_iterator<char_type, traits_type> _I;
976 _I __i(*this);
977 _I __eof;
978 for (; __i != __eof && __n > 1; ++__i, ++__s, ++__c)
979 {
980 char_type __ch = *__i;
981 if (traits_type::eq(__ch, __dlm))
982 break;
983 *__s = __ch;
984 }
985 *__s = char_type();
986 ios_base::iostate __err = ios_base::goodbit;
987 if (__i == __eof)
988 __err |= ios_base::eofbit;
989 if (__c == 0)
990 __err |= ios_base::failbit;
991 this->setstate(__err);
992 }
993 else
994 this->setstate(ios_base::failbit);
995 __gc_ = __c;
996 }
997#ifndef _LIBCPP_NO_EXCEPTIONS
998 }
999 catch (...)
1000 {
1001 this->__set_badbit_and_consider_rethrow();
1002 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001003#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001004 return *this;
1005}
1006
1007template<class _CharT, class _Traits>
1008inline _LIBCPP_INLINE_VISIBILITY
1009basic_istream<_CharT, _Traits>&
1010basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n)
1011{
1012 return get(__s, __n, this->widen('\n'));
1013}
1014
1015template<class _CharT, class _Traits>
1016basic_istream<_CharT, _Traits>&
1017basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb,
1018 char_type __dlm)
1019{
1020 __gc_ = 0;
1021#ifndef _LIBCPP_NO_EXCEPTIONS
1022 try
1023 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001024#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001025 sentry __sen(*this, true);
1026 if (__sen)
1027 {
1028 streamsize __c = 0;
1029 ios_base::iostate __err = ios_base::goodbit;
1030#ifndef _LIBCPP_NO_EXCEPTIONS
1031 try
1032 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001033#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001034 typedef istreambuf_iterator<char_type, traits_type> _I;
1035 typedef ostreambuf_iterator<char_type, traits_type> _O;
1036 _I __i(*this);
1037 _I __eof;
1038 _O __o(&__sb);
1039 for (; __i != __eof; ++__i, ++__o, ++__c)
1040 {
1041 char_type __ch = *__i;
1042 if (traits_type::eq(__ch, __dlm))
1043 break;
1044 *__o = __ch;
1045 if (__o.failed())
1046 break;
1047 }
1048 if (__i == __eof)
1049 __err |= ios_base::eofbit;
1050#ifndef _LIBCPP_NO_EXCEPTIONS
1051 }
1052 catch (...)
1053 {
1054 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001055#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001056 if (__c == 0)
1057 __err |= ios_base::failbit;
1058 this->setstate(__err);
1059 __gc_ = __c;
1060 }
1061#ifndef _LIBCPP_NO_EXCEPTIONS
1062 }
1063 catch (...)
1064 {
1065 this->__set_badbit_and_consider_rethrow();
1066 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001067#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001068 return *this;
1069}
1070
1071template<class _CharT, class _Traits>
1072inline _LIBCPP_INLINE_VISIBILITY
1073basic_istream<_CharT, _Traits>&
1074basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb)
1075{
1076 return get(__sb, this->widen('\n'));
1077}
1078
1079template<class _CharT, class _Traits>
1080basic_istream<_CharT, _Traits>&
1081basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm)
1082{
1083 __gc_ = 0;
1084#ifndef _LIBCPP_NO_EXCEPTIONS
1085 try
1086 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001087#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001088 sentry __sen(*this, true);
1089 if (__sen)
1090 {
1091 streamsize __c = 0;
1092 typedef istreambuf_iterator<char_type, traits_type> _I;
1093 _I __i(*this);
1094 _I __eof;
1095 for (; __i != __eof; ++__s, --__n)
1096 {
1097 char_type __ch = *__i;
1098 ++__i;
1099 ++__c;
1100 if (traits_type::eq(__ch, __dlm))
1101 break;
1102 if (__n < 2)
1103 {
1104 this->setstate(ios_base::failbit);
1105 break;
1106 }
1107 *__s = __ch;
1108 }
1109 if (__n)
1110 *__s = char_type();
1111 ios_base::iostate __err = ios_base::goodbit;
1112 if (__i == __eof)
1113 __err |= ios_base::eofbit;
1114 if (__c == 0)
1115 __err |= ios_base::failbit;
1116 this->setstate(__err);
1117 __gc_ = __c;
1118 }
1119#ifndef _LIBCPP_NO_EXCEPTIONS
1120 }
1121 catch (...)
1122 {
1123 this->__set_badbit_and_consider_rethrow();
1124 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001125#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001126 return *this;
1127}
1128
1129template<class _CharT, class _Traits>
1130inline _LIBCPP_INLINE_VISIBILITY
1131basic_istream<_CharT, _Traits>&
1132basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n)
1133{
1134 return getline(__s, __n, this->widen('\n'));
1135}
1136
1137template<class _CharT, class _Traits>
1138basic_istream<_CharT, _Traits>&
1139basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
1140{
1141 __gc_ = 0;
1142#ifndef _LIBCPP_NO_EXCEPTIONS
1143 try
1144 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001145#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001146 sentry __sen(*this, true);
1147 if (__sen)
1148 {
1149 streamsize __c = 0;
1150 typedef istreambuf_iterator<char_type, traits_type> _I;
1151 _I __i(*this);
1152 _I __eof;
1153 if (__n != numeric_limits<streamsize>::max())
1154 {
1155 for (; __n > 0 && __i != __eof; --__n)
1156 {
1157 char_type __ch = *__i;
1158 ++__i;
1159 ++__c;
1160 if (traits_type::eq(__ch, __dlm))
1161 break;
1162 }
1163 }
1164 else
1165 {
1166 while (__i != __eof)
1167 {
1168 char_type __ch = *__i;
1169 ++__i;
1170 ++__c;
1171 if (traits_type::eq(__ch, __dlm))
1172 break;
1173 }
1174 }
1175 if (__i == __eof)
1176 this->setstate(ios_base::eofbit);
1177 __gc_ = __c;
1178 }
1179#ifndef _LIBCPP_NO_EXCEPTIONS
1180 }
1181 catch (...)
1182 {
1183 this->__set_badbit_and_consider_rethrow();
1184 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001185#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001186 return *this;
1187}
1188
1189template<class _CharT, class _Traits>
1190typename basic_istream<_CharT, _Traits>::int_type
1191basic_istream<_CharT, _Traits>::peek()
1192{
1193 __gc_ = 0;
1194 int_type __r = traits_type::eof();
1195#ifndef _LIBCPP_NO_EXCEPTIONS
1196 try
1197 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001198#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001199 sentry __sen(*this, true);
1200 if (__sen)
1201 __r = this->rdbuf()->sgetc();
1202#ifndef _LIBCPP_NO_EXCEPTIONS
1203 }
1204 catch (...)
1205 {
1206 this->__set_badbit_and_consider_rethrow();
1207 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001208#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001209 return __r;
1210}
1211
1212template<class _CharT, class _Traits>
1213basic_istream<_CharT, _Traits>&
1214basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
1215{
1216 __gc_ = 0;
1217#ifndef _LIBCPP_NO_EXCEPTIONS
1218 try
1219 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001220#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001221 sentry __sen(*this, true);
1222 if (__sen)
1223 {
1224 streamsize __c = 0;
1225 typedef istreambuf_iterator<char_type, traits_type> _I;
1226 _I __i(*this);
1227 _I __eof;
1228 for (; __i != __eof && __n > 0; ++__i, ++__s, ++__c, --__n)
1229 *__s = *__i;
1230 if (__i == __eof)
1231 {
1232 ios_base::iostate __err = ios_base::eofbit;
1233 if (__n > 0)
1234 __err |= ios_base::failbit;
1235 this->setstate(__err);
1236 }
1237 __gc_ = __c;
1238 }
1239 else
1240 this->setstate(ios_base::failbit);
1241#ifndef _LIBCPP_NO_EXCEPTIONS
1242 }
1243 catch (...)
1244 {
1245 this->__set_badbit_and_consider_rethrow();
1246 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001247#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001248 return *this;
1249}
1250
1251template<class _CharT, class _Traits>
1252streamsize
1253basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
1254{
1255 __gc_ = 0;
1256 streamsize __c = 0;
1257#ifndef _LIBCPP_NO_EXCEPTIONS
1258 try
1259 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001260#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001261 sentry __sen(*this, true);
1262 if (__sen)
1263 {
1264 typedef istreambuf_iterator<char_type, traits_type> _I;
1265 _I __i(*this);
1266 _I __eof;
1267 __c = this->rdbuf()->in_avail();
1268 switch (__c)
1269 {
1270 case -1:
1271 __i = __eof;
1272 break;
1273 case 0:
1274 break;
1275 default:
Howard Hinnant6cf5d8c2011-02-14 19:12:38 +00001276 __c = _STD::min(__c, __n);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001277 for (streamsize __k = 0; __k < __c; ++__k, ++__s, ++__i)
1278 *__s = *__i;
1279 }
1280 if (__i == __eof)
1281 this->setstate(ios_base::eofbit);
1282 __gc_ = __c;
1283 }
1284 else
1285 this->setstate(ios_base::failbit);
1286#ifndef _LIBCPP_NO_EXCEPTIONS
1287 }
1288 catch (...)
1289 {
1290 this->__set_badbit_and_consider_rethrow();
1291 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001292#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001293 return __c;
1294}
1295
1296template<class _CharT, class _Traits>
1297basic_istream<_CharT, _Traits>&
1298basic_istream<_CharT, _Traits>::putback(char_type __c)
1299{
1300 __gc_ = 0;
1301#ifndef _LIBCPP_NO_EXCEPTIONS
1302 try
1303 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001304#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001305 sentry __sen(*this, true);
1306 if (__sen)
1307 {
1308 if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof())
1309 this->setstate(ios_base::badbit);
1310 }
1311 else
1312 this->setstate(ios_base::failbit);
1313#ifndef _LIBCPP_NO_EXCEPTIONS
1314 }
1315 catch (...)
1316 {
1317 this->__set_badbit_and_consider_rethrow();
1318 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001319#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001320 return *this;
1321}
1322
1323template<class _CharT, class _Traits>
1324basic_istream<_CharT, _Traits>&
1325basic_istream<_CharT, _Traits>::unget()
1326{
1327 __gc_ = 0;
1328#ifndef _LIBCPP_NO_EXCEPTIONS
1329 try
1330 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001331#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001332 sentry __sen(*this, true);
1333 if (__sen)
1334 {
1335 if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof())
1336 this->setstate(ios_base::badbit);
1337 }
1338 else
1339 this->setstate(ios_base::failbit);
1340#ifndef _LIBCPP_NO_EXCEPTIONS
1341 }
1342 catch (...)
1343 {
1344 this->__set_badbit_and_consider_rethrow();
1345 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001346#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001347 return *this;
1348}
1349
1350template<class _CharT, class _Traits>
1351int
1352basic_istream<_CharT, _Traits>::sync()
1353{
1354 int __r = 0;
1355#ifndef _LIBCPP_NO_EXCEPTIONS
1356 try
1357 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001358#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001359 sentry __sen(*this, true);
1360 if (__sen)
1361 {
1362 if (this->rdbuf() == 0)
1363 return -1;
1364 if (this->rdbuf()->pubsync() == -1)
1365 {
1366 this->setstate(ios_base::badbit);
1367 return -1;
1368 }
1369 }
1370#ifndef _LIBCPP_NO_EXCEPTIONS
1371 }
1372 catch (...)
1373 {
1374 this->__set_badbit_and_consider_rethrow();
1375 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001376#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001377 return __r;
1378}
1379
1380template<class _CharT, class _Traits>
1381typename basic_istream<_CharT, _Traits>::pos_type
1382basic_istream<_CharT, _Traits>::tellg()
1383{
1384 pos_type __r(-1);
1385#ifndef _LIBCPP_NO_EXCEPTIONS
1386 try
1387 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001388#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001389 sentry __sen(*this, true);
1390 if (__sen)
1391 __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
1392#ifndef _LIBCPP_NO_EXCEPTIONS
1393 }
1394 catch (...)
1395 {
1396 this->__set_badbit_and_consider_rethrow();
1397 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001398#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001399 return __r;
1400}
1401
1402template<class _CharT, class _Traits>
1403basic_istream<_CharT, _Traits>&
1404basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
1405{
1406#ifndef _LIBCPP_NO_EXCEPTIONS
1407 try
1408 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001409#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001410 sentry __sen(*this, true);
1411 if (__sen)
1412 if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
1413 this->setstate(ios_base::failbit);
1414#ifndef _LIBCPP_NO_EXCEPTIONS
1415 }
1416 catch (...)
1417 {
1418 this->__set_badbit_and_consider_rethrow();
1419 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001420#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001421 return *this;
1422}
1423
1424template<class _CharT, class _Traits>
1425basic_istream<_CharT, _Traits>&
1426basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
1427{
1428#ifndef _LIBCPP_NO_EXCEPTIONS
1429 try
1430 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001431#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001432 sentry __sen(*this, true);
1433 if (__sen)
1434 this->rdbuf()->pubseekoff(__off, __dir, ios_base::in);
1435#ifndef _LIBCPP_NO_EXCEPTIONS
1436 }
1437 catch (...)
1438 {
1439 this->__set_badbit_and_consider_rethrow();
1440 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001441#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001442 return *this;
1443}
1444
1445template <class _CharT, class _Traits>
1446basic_istream<_CharT, _Traits>&
1447ws(basic_istream<_CharT, _Traits>& __is)
1448{
1449#ifndef _LIBCPP_NO_EXCEPTIONS
1450 try
1451 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001452#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001453 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1454 if (__sen)
1455 {
1456 typedef istreambuf_iterator<_CharT, _Traits> _I;
1457 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1458 _I __i(__is);
1459 _I __eof;
1460 for (; __i != __eof; ++__i)
1461 if (!__ct.is(__ct.space, *__i))
1462 break;
1463 if (__i == __eof)
1464 __is.setstate(ios_base::failbit | ios_base::eofbit);
1465 }
1466#ifndef _LIBCPP_NO_EXCEPTIONS
1467 }
1468 catch (...)
1469 {
1470 __is.__set_badbit_and_consider_rethrow();
1471 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001472#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001473 return __is;
1474}
1475
Howard Hinnant73d21a42010-09-04 23:28:19 +00001476#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001477
1478template <class _CharT, class _Traits, class _Tp>
1479inline _LIBCPP_INLINE_VISIBILITY
1480basic_istream<_CharT, _Traits>&
1481operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
1482{
1483 __is >> __x;
1484 return __is;
1485}
1486
Howard Hinnant73d21a42010-09-04 23:28:19 +00001487#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001488
1489template <class _CharT, class _Traits>
Howard Hinnant68a8e902010-09-22 15:29:08 +00001490class _LIBCPP_VISIBLE basic_iostream
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001491 : public basic_istream<_CharT, _Traits>,
1492 public basic_ostream<_CharT, _Traits>
1493{
1494public:
1495 // types:
1496 typedef _CharT char_type;
1497 typedef _Traits traits_type;
1498 typedef typename traits_type::int_type int_type;
1499 typedef typename traits_type::pos_type pos_type;
1500 typedef typename traits_type::off_type off_type;
1501
1502 // constructor/destructor
1503 explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb);
1504 virtual ~basic_iostream();
1505protected:
Howard Hinnant73d21a42010-09-04 23:28:19 +00001506#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001507 basic_iostream(basic_iostream&& __rhs);
1508#endif
1509
1510 // assign/swap
Howard Hinnant73d21a42010-09-04 23:28:19 +00001511#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001512 basic_iostream& operator=(basic_iostream&& __rhs);
1513#endif
1514 void swap(basic_iostream& __rhs);
1515public:
1516};
1517
1518template <class _CharT, class _Traits>
1519inline _LIBCPP_INLINE_VISIBILITY
1520basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
1521 : basic_istream<_CharT, _Traits>(__sb)
1522{
1523}
1524
Howard Hinnant73d21a42010-09-04 23:28:19 +00001525#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001526
1527template <class _CharT, class _Traits>
1528inline _LIBCPP_INLINE_VISIBILITY
1529basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
1530 : basic_istream<_CharT, _Traits>(_STD::move(__rhs))
1531{
1532}
1533
1534template <class _CharT, class _Traits>
1535inline _LIBCPP_INLINE_VISIBILITY
1536basic_iostream<_CharT, _Traits>&
1537basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
1538{
1539 swap(__rhs);
1540 return *this;
1541}
1542
Howard Hinnant73d21a42010-09-04 23:28:19 +00001543#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001544
1545template <class _CharT, class _Traits>
1546basic_iostream<_CharT, _Traits>::~basic_iostream()
1547{
1548}
1549
1550template <class _CharT, class _Traits>
1551inline _LIBCPP_INLINE_VISIBILITY
1552void
1553basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs)
1554{
1555 basic_istream<char_type, traits_type>::swap(__rhs);
1556}
1557
1558template<class _CharT, class _Traits, class _Allocator>
1559basic_istream<_CharT, _Traits>&
1560operator>>(basic_istream<_CharT, _Traits>& __is,
1561 basic_string<_CharT, _Traits, _Allocator>& __str)
1562{
1563#ifndef _LIBCPP_NO_EXCEPTIONS
1564 try
1565 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001566#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001567 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
1568 if (__sen)
1569 {
1570 __str.clear();
1571 typedef istreambuf_iterator<_CharT, _Traits> _I;
1572 streamsize __n = __is.width();
1573 if (__n == 0)
1574 __n = __str.max_size();
1575 if (__n < 0)
1576 __n = numeric_limits<streamsize>::max();
1577 streamsize __c = 0;
1578 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1579 _I __i(__is);
1580 _I __eof;
1581 for (; __i != __eof && __c < __n; ++__i, ++__c)
1582 {
1583 _CharT __ch = *__i;
1584 if (__ct.is(__ct.space, __ch))
1585 break;
1586 __str.push_back(__ch);
1587 }
1588 __is.width(0);
1589 ios_base::iostate __err = ios_base::goodbit;
1590 if (__i == __eof)
1591 __err |= ios_base::eofbit;
1592 if (__c == 0)
1593 __err |= ios_base::failbit;
1594 __is.setstate(__err);
1595 }
1596 else
1597 __is.setstate(ios_base::failbit);
1598#ifndef _LIBCPP_NO_EXCEPTIONS
1599 }
1600 catch (...)
1601 {
1602 __is.__set_badbit_and_consider_rethrow();
1603 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001604#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001605 return __is;
1606}
1607
1608template<class _CharT, class _Traits, class _Allocator>
Howard Hinnant324bb032010-08-22 00:02:43 +00001609basic_istream<_CharT, _Traits>&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001610getline(basic_istream<_CharT, _Traits>& __is,
1611 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
1612{
1613#ifndef _LIBCPP_NO_EXCEPTIONS
1614 try
1615 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001616#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001617 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1618 if (__sen)
1619 {
1620 __str.clear();
1621 streamsize __c = 0;
1622 typedef istreambuf_iterator<_CharT, _Traits> _I;
1623 _I __i(__is);
1624 _I __eof;
1625 streamsize __n = __str.max_size();
1626 if (__n < 0)
1627 __n = numeric_limits<streamsize>::max();
1628 for (; __i != __eof;)
1629 {
1630 _CharT __ch = *__i;
1631 ++__i;
1632 ++__c;
1633 if (_Traits::eq(__ch, __dlm))
1634 break;
1635 if (__c == __n)
1636 {
1637 __is.setstate(ios_base::failbit);
1638 break;
1639 }
1640 __str.push_back(__ch);
1641 }
1642 ios_base::iostate __err = ios_base::goodbit;
1643 if (__i == __eof)
1644 __err |= ios_base::eofbit;
1645 if (__c == 0)
1646 __err |= ios_base::failbit;
1647 __is.setstate(__err);
1648 }
1649#ifndef _LIBCPP_NO_EXCEPTIONS
1650 }
1651 catch (...)
1652 {
1653 __is.__set_badbit_and_consider_rethrow();
1654 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001655#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001656 return __is;
1657}
1658
1659template<class _CharT, class _Traits, class _Allocator>
Howard Hinnant68a8e902010-09-22 15:29:08 +00001660inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant324bb032010-08-22 00:02:43 +00001661basic_istream<_CharT, _Traits>&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001662getline(basic_istream<_CharT, _Traits>& __is,
1663 basic_string<_CharT, _Traits, _Allocator>& __str)
1664{
1665 return getline(__is, __str, __is.widen('\n'));
1666}
1667
Howard Hinnant73d21a42010-09-04 23:28:19 +00001668#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001669
1670template<class _CharT, class _Traits, class _Allocator>
Howard Hinnant68a8e902010-09-22 15:29:08 +00001671inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant324bb032010-08-22 00:02:43 +00001672basic_istream<_CharT, _Traits>&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001673getline(basic_istream<_CharT, _Traits>&& __is,
1674 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
1675{
1676 return getline(__is, __str, __dlm);
1677}
1678
1679template<class _CharT, class _Traits, class _Allocator>
Howard Hinnant68a8e902010-09-22 15:29:08 +00001680inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant324bb032010-08-22 00:02:43 +00001681basic_istream<_CharT, _Traits>&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001682getline(basic_istream<_CharT, _Traits>&& __is,
1683 basic_string<_CharT, _Traits, _Allocator>& __str)
1684{
1685 return getline(__is, __str, __is.widen('\n'));
1686}
1687
Howard Hinnant73d21a42010-09-04 23:28:19 +00001688#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001689
1690template <class _CharT, class _Traits, size_t _Size>
1691basic_istream<_CharT, _Traits>&
1692operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
1693{
1694#ifndef _LIBCPP_NO_EXCEPTIONS
1695 try
1696 {
Howard Hinnant324bb032010-08-22 00:02:43 +00001697#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001698 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
1699 if (__sen)
1700 {
1701 basic_string<_CharT, _Traits> __str;
1702 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1703 typedef istreambuf_iterator<_CharT, _Traits> _I;
1704 streamsize __c = 0;
1705 _CharT __zero = __ct.widen('0');
1706 _CharT __one = __ct.widen('1');
1707 _I __i(__is);
1708 _I __eof;
1709 for (; __i != __eof && __c < _Size; ++__i, ++__c)
1710 {
1711 _CharT __ch = *__i;
1712 if (__ch != __zero && __ch != __one)
1713 break;
1714 __str.push_back(__ch);
1715 }
1716 __is.width(0);
1717 __x = bitset<_Size>(__str);
1718 ios_base::iostate __err = ios_base::goodbit;
1719 if (__i == __eof)
1720 __err |= ios_base::eofbit;
1721 if (__c == 0)
1722 __err |= ios_base::failbit;
1723 __is.setstate(__err);
1724 }
1725 else
1726 __is.setstate(ios_base::failbit);
1727#ifndef _LIBCPP_NO_EXCEPTIONS
1728 }
1729 catch (...)
1730 {
1731 __is.__set_badbit_and_consider_rethrow();
1732 }
Howard Hinnant324bb032010-08-22 00:02:43 +00001733#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001734 return __is;
1735}
1736
1737extern template class basic_istream<char>;
1738extern template class basic_istream<wchar_t>;
1739extern template class basic_iostream<char>;
1740
1741_LIBCPP_END_NAMESPACE_STD
1742
1743#endif // _LIBCPP_ISTREAM