2 //===--------------------------- istream ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_ISTREAM
12 #define _LIBCPP_ISTREAM
17 template <class charT, class traits = char_traits<charT> >
19 : virtual public basic_ios<charT,traits>
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;
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();
34 // 27.7.1.1.2 Assign/swap:
35 basic_istream& operator=(basic_istream&& rhs);
36 void swap(basic_istream& rhs);
38 // 27.7.1.1.3 Prefix/suffix:
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);
61 // 27.7.1.3 Unformatted input:
62 streamsize gcount() const;
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);
70 basic_istream& getline(char_type* s, streamsize n);
71 basic_istream& getline(char_type* s, streamsize n, char_type delim);
73 basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof());
75 basic_istream& read (char_type* s, streamsize n);
76 streamsize readsome(char_type* s, streamsize n);
78 basic_istream& putback(char_type c);
79 basic_istream& unget();
83 basic_istream& seekg(pos_type);
84 basic_istream& seekg(off_type, ios_base::seekdir);
87 // 27.7.1.2.3 character extraction templates:
88 template<class charT, class traits>
89 basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT&);
91 template<class traits>
92 basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char&);
94 template<class traits>
95 basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char&);
97 template<class charT, class traits>
98 basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT*);
100 template<class traits>
101 basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char*);
103 template<class traits>
104 basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char*);
106 template <class charT, class traits>
108 swap(basic_istream<charT, traits>& x, basic_istream<charT, traits>& y);
110 typedef basic_istream<char> istream;
111 typedef basic_istream<wchar_t> wistream;
113 template <class charT, class traits = char_traits<charT> >
114 class basic_iostream :
115 public basic_istream<charT,traits>,
116 public basic_ostream<charT,traits>
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;
126 // constructor/destructor
127 explicit basic_iostream(basic_streambuf<char_type, traits_type>* sb);
128 basic_iostream(basic_iostream&& rhs);
129 virtual ~basic_iostream();
132 basic_iostream& operator=(basic_iostream&& rhs);
133 void swap(basic_iostream& rhs);
136 template <class charT, class traits>
138 swap(basic_iostream<charT, traits>& x, basic_iostream<charT, traits>& y);
140 typedef basic_iostream<char> iostream;
141 typedef basic_iostream<wchar_t> wiostream;
143 template <class charT, class traits>
144 basic_istream<charT,traits>&
145 ws(basic_istream<charT,traits>& is);
147 template <class charT, class traits, class T>
148 basic_istream<charT, traits>&
149 operator>>(basic_istream<charT, traits>&& is, T& x);
158 #include <__undef_min_max>
160 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
161 #pragma GCC system_header
164 _LIBCPP_BEGIN_NAMESPACE_STD
166 template <class _CharT, class _Traits>
167 class _LIBCPP_TYPE_VIS basic_istream
168 : virtual public basic_ios<_CharT, _Traits>
172 // types (inherited from basic_ios (27.5.4)):
173 typedef _CharT char_type;
174 typedef _Traits traits_type;
175 typedef typename traits_type::int_type int_type;
176 typedef typename traits_type::pos_type pos_type;
177 typedef typename traits_type::off_type off_type;
179 // 27.7.1.1.1 Constructor/destructor:
180 explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb);
181 virtual ~basic_istream();
183 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
184 _LIBCPP_INLINE_VISIBILITY
185 basic_istream(basic_istream&& __rhs);
188 // 27.7.1.1.2 Assign/swap:
189 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
190 _LIBCPP_INLINE_VISIBILITY
191 basic_istream& operator=(basic_istream&& __rhs);
193 void swap(basic_istream& __rhs);
196 // 27.7.1.1.3 Prefix/suffix:
197 class _LIBCPP_TYPE_VIS sentry;
199 // 27.7.1.2 Formatted input:
200 basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&));
201 basic_istream& operator>>(basic_ios<char_type, traits_type>&
202 (*__pf)(basic_ios<char_type, traits_type>&));
203 basic_istream& operator>>(ios_base& (*__pf)(ios_base&));
204 basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb);
205 basic_istream& operator>>(bool& __n);
206 basic_istream& operator>>(short& __n);
207 basic_istream& operator>>(unsigned short& __n);
208 basic_istream& operator>>(int& __n);
209 basic_istream& operator>>(unsigned int& __n);
210 basic_istream& operator>>(long& __n);
211 basic_istream& operator>>(unsigned long& __n);
212 basic_istream& operator>>(long long& __n);
213 basic_istream& operator>>(unsigned long long& __n);
214 basic_istream& operator>>(float& __f);
215 basic_istream& operator>>(double& __f);
216 basic_istream& operator>>(long double& __f);
217 basic_istream& operator>>(void*& __p);
219 // 27.7.1.3 Unformatted input:
220 _LIBCPP_INLINE_VISIBILITY
221 streamsize gcount() const {return __gc_;}
223 basic_istream& get(char_type& __c);
224 basic_istream& get(char_type* __s, streamsize __n);
225 basic_istream& get(char_type* __s, streamsize __n, char_type __dlm);
226 basic_istream& get(basic_streambuf<char_type, traits_type>& __sb);
227 basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm);
229 basic_istream& getline(char_type* __s, streamsize __n);
230 basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
232 basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
234 basic_istream& read (char_type* __s, streamsize __n);
235 streamsize readsome(char_type* __s, streamsize __n);
237 basic_istream& putback(char_type __c);
238 basic_istream& unget();
242 basic_istream& seekg(pos_type __pos);
243 basic_istream& seekg(off_type __off, ios_base::seekdir __dir);
246 template <class _CharT, class _Traits>
247 class _LIBCPP_TYPE_VIS basic_istream<_CharT, _Traits>::sentry
251 sentry(const sentry&); // = delete;
252 sentry& operator=(const sentry&); // = delete;
255 explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
256 // ~sentry() = default;
258 _LIBCPP_INLINE_VISIBILITY
260 operator bool() const {return __ok_;}
263 template <class _CharT, class _Traits>
264 basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is,
272 if (!__noskipws && (__is.flags() & ios_base::skipws))
274 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
275 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
278 for (; __i != __eof; ++__i)
279 if (!__ct.is(__ct.space, *__i))
282 __is.setstate(ios_base::failbit | ios_base::eofbit);
287 __is.setstate(ios_base::failbit);
290 template <class _CharT, class _Traits>
291 inline _LIBCPP_INLINE_VISIBILITY
292 basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf<char_type, traits_type>* __sb)
298 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
300 template <class _CharT, class _Traits>
301 inline _LIBCPP_INLINE_VISIBILITY
302 basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
309 template <class _CharT, class _Traits>
310 inline _LIBCPP_INLINE_VISIBILITY
311 basic_istream<_CharT, _Traits>&
312 basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
318 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
320 template <class _CharT, class _Traits>
321 basic_istream<_CharT, _Traits>::~basic_istream()
325 template <class _CharT, class _Traits>
326 inline _LIBCPP_INLINE_VISIBILITY
328 basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
330 _VSTD::swap(__gc_, __rhs.__gc_);
331 basic_ios<char_type, traits_type>::swap(__rhs);
334 template <class _CharT, class _Traits>
335 basic_istream<_CharT, _Traits>&
336 basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
338 #ifndef _LIBCPP_NO_EXCEPTIONS
341 #endif // _LIBCPP_NO_EXCEPTIONS
345 typedef istreambuf_iterator<char_type, traits_type> _Ip;
346 typedef num_get<char_type, _Ip> _Fp;
347 ios_base::iostate __err = ios_base::goodbit;
348 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
349 this->setstate(__err);
351 #ifndef _LIBCPP_NO_EXCEPTIONS
355 this->__set_badbit_and_consider_rethrow();
357 #endif // _LIBCPP_NO_EXCEPTIONS
361 template <class _CharT, class _Traits>
362 basic_istream<_CharT, _Traits>&
363 basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n)
365 #ifndef _LIBCPP_NO_EXCEPTIONS
368 #endif // _LIBCPP_NO_EXCEPTIONS
372 typedef istreambuf_iterator<char_type, traits_type> _Ip;
373 typedef num_get<char_type, _Ip> _Fp;
374 ios_base::iostate __err = ios_base::goodbit;
375 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
376 this->setstate(__err);
378 #ifndef _LIBCPP_NO_EXCEPTIONS
382 this->__set_badbit_and_consider_rethrow();
384 #endif // _LIBCPP_NO_EXCEPTIONS
388 template <class _CharT, class _Traits>
389 basic_istream<_CharT, _Traits>&
390 basic_istream<_CharT, _Traits>::operator>>(long& __n)
392 #ifndef _LIBCPP_NO_EXCEPTIONS
395 #endif // _LIBCPP_NO_EXCEPTIONS
399 typedef istreambuf_iterator<char_type, traits_type> _Ip;
400 typedef num_get<char_type, _Ip> _Fp;
401 ios_base::iostate __err = ios_base::goodbit;
402 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
403 this->setstate(__err);
405 #ifndef _LIBCPP_NO_EXCEPTIONS
409 this->__set_badbit_and_consider_rethrow();
411 #endif // _LIBCPP_NO_EXCEPTIONS
415 template <class _CharT, class _Traits>
416 basic_istream<_CharT, _Traits>&
417 basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n)
419 #ifndef _LIBCPP_NO_EXCEPTIONS
422 #endif // _LIBCPP_NO_EXCEPTIONS
426 typedef istreambuf_iterator<char_type, traits_type> _Ip;
427 typedef num_get<char_type, _Ip> _Fp;
428 ios_base::iostate __err = ios_base::goodbit;
429 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
430 this->setstate(__err);
432 #ifndef _LIBCPP_NO_EXCEPTIONS
436 this->__set_badbit_and_consider_rethrow();
438 #endif // _LIBCPP_NO_EXCEPTIONS
442 template <class _CharT, class _Traits>
443 basic_istream<_CharT, _Traits>&
444 basic_istream<_CharT, _Traits>::operator>>(long long& __n)
446 #ifndef _LIBCPP_NO_EXCEPTIONS
449 #endif // _LIBCPP_NO_EXCEPTIONS
453 typedef istreambuf_iterator<char_type, traits_type> _Ip;
454 typedef num_get<char_type, _Ip> _Fp;
455 ios_base::iostate __err = ios_base::goodbit;
456 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
457 this->setstate(__err);
459 #ifndef _LIBCPP_NO_EXCEPTIONS
463 this->__set_badbit_and_consider_rethrow();
465 #endif // _LIBCPP_NO_EXCEPTIONS
469 template <class _CharT, class _Traits>
470 basic_istream<_CharT, _Traits>&
471 basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n)
473 #ifndef _LIBCPP_NO_EXCEPTIONS
476 #endif // _LIBCPP_NO_EXCEPTIONS
480 typedef istreambuf_iterator<char_type, traits_type> _Ip;
481 typedef num_get<char_type, _Ip> _Fp;
482 ios_base::iostate __err = ios_base::goodbit;
483 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
484 this->setstate(__err);
486 #ifndef _LIBCPP_NO_EXCEPTIONS
490 this->__set_badbit_and_consider_rethrow();
492 #endif // _LIBCPP_NO_EXCEPTIONS
496 template <class _CharT, class _Traits>
497 basic_istream<_CharT, _Traits>&
498 basic_istream<_CharT, _Traits>::operator>>(float& __n)
500 #ifndef _LIBCPP_NO_EXCEPTIONS
503 #endif // _LIBCPP_NO_EXCEPTIONS
507 typedef istreambuf_iterator<char_type, traits_type> _Ip;
508 typedef num_get<char_type, _Ip> _Fp;
509 ios_base::iostate __err = ios_base::goodbit;
510 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
511 this->setstate(__err);
513 #ifndef _LIBCPP_NO_EXCEPTIONS
517 this->__set_badbit_and_consider_rethrow();
519 #endif // _LIBCPP_NO_EXCEPTIONS
523 template <class _CharT, class _Traits>
524 basic_istream<_CharT, _Traits>&
525 basic_istream<_CharT, _Traits>::operator>>(double& __n)
527 #ifndef _LIBCPP_NO_EXCEPTIONS
530 #endif // _LIBCPP_NO_EXCEPTIONS
534 typedef istreambuf_iterator<char_type, traits_type> _Ip;
535 typedef num_get<char_type, _Ip> _Fp;
536 ios_base::iostate __err = ios_base::goodbit;
537 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
538 this->setstate(__err);
540 #ifndef _LIBCPP_NO_EXCEPTIONS
544 this->__set_badbit_and_consider_rethrow();
546 #endif // _LIBCPP_NO_EXCEPTIONS
550 template <class _CharT, class _Traits>
551 basic_istream<_CharT, _Traits>&
552 basic_istream<_CharT, _Traits>::operator>>(long double& __n)
554 #ifndef _LIBCPP_NO_EXCEPTIONS
557 #endif // _LIBCPP_NO_EXCEPTIONS
561 typedef istreambuf_iterator<char_type, traits_type> _Ip;
562 typedef num_get<char_type, _Ip> _Fp;
563 ios_base::iostate __err = ios_base::goodbit;
564 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
565 this->setstate(__err);
567 #ifndef _LIBCPP_NO_EXCEPTIONS
571 this->__set_badbit_and_consider_rethrow();
573 #endif // _LIBCPP_NO_EXCEPTIONS
577 template <class _CharT, class _Traits>
578 basic_istream<_CharT, _Traits>&
579 basic_istream<_CharT, _Traits>::operator>>(bool& __n)
581 #ifndef _LIBCPP_NO_EXCEPTIONS
584 #endif // _LIBCPP_NO_EXCEPTIONS
588 typedef istreambuf_iterator<char_type, traits_type> _Ip;
589 typedef num_get<char_type, _Ip> _Fp;
590 ios_base::iostate __err = ios_base::goodbit;
591 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
592 this->setstate(__err);
594 #ifndef _LIBCPP_NO_EXCEPTIONS
598 this->__set_badbit_and_consider_rethrow();
600 #endif // _LIBCPP_NO_EXCEPTIONS
604 template <class _CharT, class _Traits>
605 basic_istream<_CharT, _Traits>&
606 basic_istream<_CharT, _Traits>::operator>>(void*& __n)
608 #ifndef _LIBCPP_NO_EXCEPTIONS
611 #endif // _LIBCPP_NO_EXCEPTIONS
615 typedef istreambuf_iterator<char_type, traits_type> _Ip;
616 typedef num_get<char_type, _Ip> _Fp;
617 ios_base::iostate __err = ios_base::goodbit;
618 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
619 this->setstate(__err);
621 #ifndef _LIBCPP_NO_EXCEPTIONS
625 this->__set_badbit_and_consider_rethrow();
627 #endif // _LIBCPP_NO_EXCEPTIONS
631 template <class _CharT, class _Traits>
632 basic_istream<_CharT, _Traits>&
633 basic_istream<_CharT, _Traits>::operator>>(short& __n)
635 #ifndef _LIBCPP_NO_EXCEPTIONS
638 #endif // _LIBCPP_NO_EXCEPTIONS
642 typedef istreambuf_iterator<char_type, traits_type> _Ip;
643 typedef num_get<char_type, _Ip> _Fp;
644 ios_base::iostate __err = ios_base::goodbit;
646 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp);
647 if (__temp < numeric_limits<short>::min())
649 __err |= ios_base::failbit;
650 __n = numeric_limits<short>::min();
652 else if (__temp > numeric_limits<short>::max())
654 __err |= ios_base::failbit;
655 __n = numeric_limits<short>::max();
658 __n = static_cast<short>(__temp);
659 this->setstate(__err);
661 #ifndef _LIBCPP_NO_EXCEPTIONS
665 this->__set_badbit_and_consider_rethrow();
667 #endif // _LIBCPP_NO_EXCEPTIONS
671 template <class _CharT, class _Traits>
672 basic_istream<_CharT, _Traits>&
673 basic_istream<_CharT, _Traits>::operator>>(int& __n)
675 #ifndef _LIBCPP_NO_EXCEPTIONS
678 #endif // _LIBCPP_NO_EXCEPTIONS
682 typedef istreambuf_iterator<char_type, traits_type> _Ip;
683 typedef num_get<char_type, _Ip> _Fp;
684 ios_base::iostate __err = ios_base::goodbit;
686 use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp);
687 if (__temp < numeric_limits<int>::min())
689 __err |= ios_base::failbit;
690 __n = numeric_limits<int>::min();
692 else if (__temp > numeric_limits<int>::max())
694 __err |= ios_base::failbit;
695 __n = numeric_limits<int>::max();
698 __n = static_cast<int>(__temp);
699 this->setstate(__err);
701 #ifndef _LIBCPP_NO_EXCEPTIONS
705 this->__set_badbit_and_consider_rethrow();
707 #endif // _LIBCPP_NO_EXCEPTIONS
711 template <class _CharT, class _Traits>
712 inline _LIBCPP_INLINE_VISIBILITY
713 basic_istream<_CharT, _Traits>&
714 basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&))
719 template <class _CharT, class _Traits>
720 inline _LIBCPP_INLINE_VISIBILITY
721 basic_istream<_CharT, _Traits>&
722 basic_istream<_CharT, _Traits>::operator>>(basic_ios<char_type, traits_type>&
723 (*__pf)(basic_ios<char_type, traits_type>&))
729 template <class _CharT, class _Traits>
730 inline _LIBCPP_INLINE_VISIBILITY
731 basic_istream<_CharT, _Traits>&
732 basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
738 template<class _CharT, class _Traits>
739 basic_istream<_CharT, _Traits>&
740 operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s)
742 #ifndef _LIBCPP_NO_EXCEPTIONS
745 #endif // _LIBCPP_NO_EXCEPTIONS
746 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
749 streamsize __n = __is.width();
751 __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1;
753 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
754 ios_base::iostate __err = ios_base::goodbit;
757 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
758 if (_Traits::eq_int_type(__i, _Traits::eof()))
760 __err |= ios_base::eofbit;
763 _CharT __ch = _Traits::to_char_type(__i);
764 if (__ct.is(__ct.space, __ch))
768 __is.rdbuf()->sbumpc();
773 __err |= ios_base::failbit;
774 __is.setstate(__err);
776 #ifndef _LIBCPP_NO_EXCEPTIONS
780 __is.__set_badbit_and_consider_rethrow();
782 #endif // _LIBCPP_NO_EXCEPTIONS
786 template<class _Traits>
787 inline _LIBCPP_INLINE_VISIBILITY
788 basic_istream<char, _Traits>&
789 operator>>(basic_istream<char, _Traits>& __is, unsigned char* __s)
791 return __is >> (char*)__s;
794 template<class _Traits>
795 inline _LIBCPP_INLINE_VISIBILITY
796 basic_istream<char, _Traits>&
797 operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
799 return __is >> (char*)__s;
802 template<class _CharT, class _Traits>
803 basic_istream<_CharT, _Traits>&
804 operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
806 #ifndef _LIBCPP_NO_EXCEPTIONS
809 #endif // _LIBCPP_NO_EXCEPTIONS
810 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
813 typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
814 if (_Traits::eq_int_type(__i, _Traits::eof()))
815 __is.setstate(ios_base::eofbit | ios_base::failbit);
817 __c = _Traits::to_char_type(__i);
819 #ifndef _LIBCPP_NO_EXCEPTIONS
823 __is.__set_badbit_and_consider_rethrow();
825 #endif // _LIBCPP_NO_EXCEPTIONS
829 template<class _Traits>
830 inline _LIBCPP_INLINE_VISIBILITY
831 basic_istream<char, _Traits>&
832 operator>>(basic_istream<char, _Traits>& __is, unsigned char& __c)
834 return __is >> (char&)__c;
837 template<class _Traits>
838 inline _LIBCPP_INLINE_VISIBILITY
839 basic_istream<char, _Traits>&
840 operator>>(basic_istream<char, _Traits>& __is, signed char& __c)
842 return __is >> (char&)__c;
845 template<class _CharT, class _Traits>
846 basic_istream<_CharT, _Traits>&
847 basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb)
850 #ifndef _LIBCPP_NO_EXCEPTIONS
853 #endif // _LIBCPP_NO_EXCEPTIONS
854 sentry __s(*this, true);
859 #ifndef _LIBCPP_NO_EXCEPTIONS
862 #endif // _LIBCPP_NO_EXCEPTIONS
863 ios_base::iostate __err = ios_base::goodbit;
866 typename traits_type::int_type __i = this->rdbuf()->sgetc();
867 if (traits_type::eq_int_type(__i, _Traits::eof()))
869 __err |= ios_base::eofbit;
872 if (traits_type::eq_int_type(
873 __sb->sputc(traits_type::to_char_type(__i)),
877 this->rdbuf()->sbumpc();
880 __err |= ios_base::failbit;
881 this->setstate(__err);
882 #ifndef _LIBCPP_NO_EXCEPTIONS
887 this->__set_failbit_and_consider_rethrow();
889 #endif // _LIBCPP_NO_EXCEPTIONS
892 this->setstate(ios_base::failbit);
894 #ifndef _LIBCPP_NO_EXCEPTIONS
898 this->__set_badbit_and_consider_rethrow();
900 #endif // _LIBCPP_NO_EXCEPTIONS
904 template<class _CharT, class _Traits>
905 typename basic_istream<_CharT, _Traits>::int_type
906 basic_istream<_CharT, _Traits>::get()
909 int_type __r = traits_type::eof();
910 #ifndef _LIBCPP_NO_EXCEPTIONS
913 #endif // _LIBCPP_NO_EXCEPTIONS
914 sentry __s(*this, true);
917 __r = this->rdbuf()->sbumpc();
918 if (traits_type::eq_int_type(__r, traits_type::eof()))
919 this->setstate(ios_base::failbit | ios_base::eofbit);
923 #ifndef _LIBCPP_NO_EXCEPTIONS
927 this->__set_badbit_and_consider_rethrow();
929 #endif // _LIBCPP_NO_EXCEPTIONS
933 template<class _CharT, class _Traits>
934 inline _LIBCPP_INLINE_VISIBILITY
935 basic_istream<_CharT, _Traits>&
936 basic_istream<_CharT, _Traits>::get(char_type& __c)
938 int_type __ch = get();
939 if (__ch != traits_type::eof())
940 __c = traits_type::to_char_type(__ch);
944 template<class _CharT, class _Traits>
945 basic_istream<_CharT, _Traits>&
946 basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm)
949 #ifndef _LIBCPP_NO_EXCEPTIONS
952 #endif // _LIBCPP_NO_EXCEPTIONS
953 sentry __sen(*this, true);
958 ios_base::iostate __err = ios_base::goodbit;
959 while (__gc_ < __n-1)
961 int_type __i = this->rdbuf()->sgetc();
962 if (traits_type::eq_int_type(__i, traits_type::eof()))
964 __err |= ios_base::eofbit;
967 char_type __ch = traits_type::to_char_type(__i);
968 if (traits_type::eq(__ch, __dlm))
972 this->rdbuf()->sbumpc();
976 __err |= ios_base::failbit;
977 this->setstate(__err);
980 this->setstate(ios_base::failbit);
982 #ifndef _LIBCPP_NO_EXCEPTIONS
986 this->__set_badbit_and_consider_rethrow();
988 #endif // _LIBCPP_NO_EXCEPTIONS
992 template<class _CharT, class _Traits>
993 inline _LIBCPP_INLINE_VISIBILITY
994 basic_istream<_CharT, _Traits>&
995 basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n)
997 return get(__s, __n, this->widen('\n'));
1000 template<class _CharT, class _Traits>
1001 basic_istream<_CharT, _Traits>&
1002 basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb,
1006 #ifndef _LIBCPP_NO_EXCEPTIONS
1009 #endif // _LIBCPP_NO_EXCEPTIONS
1010 sentry __sen(*this, true);
1013 ios_base::iostate __err = ios_base::goodbit;
1014 #ifndef _LIBCPP_NO_EXCEPTIONS
1017 #endif // _LIBCPP_NO_EXCEPTIONS
1020 typename traits_type::int_type __i = this->rdbuf()->sgetc();
1021 if (traits_type::eq_int_type(__i, traits_type::eof()))
1023 __err |= ios_base::eofbit;
1026 char_type __ch = traits_type::to_char_type(__i);
1027 if (traits_type::eq(__ch, __dlm))
1029 if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
1032 this->rdbuf()->sbumpc();
1034 #ifndef _LIBCPP_NO_EXCEPTIONS
1039 #endif // _LIBCPP_NO_EXCEPTIONS
1041 __err |= ios_base::failbit;
1042 this->setstate(__err);
1044 #ifndef _LIBCPP_NO_EXCEPTIONS
1048 this->__set_badbit_and_consider_rethrow();
1050 #endif // _LIBCPP_NO_EXCEPTIONS
1054 template<class _CharT, class _Traits>
1055 inline _LIBCPP_INLINE_VISIBILITY
1056 basic_istream<_CharT, _Traits>&
1057 basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb)
1059 return get(__sb, this->widen('\n'));
1062 template<class _CharT, class _Traits>
1063 basic_istream<_CharT, _Traits>&
1064 basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm)
1067 #ifndef _LIBCPP_NO_EXCEPTIONS
1070 #endif // _LIBCPP_NO_EXCEPTIONS
1071 sentry __sen(*this, true);
1074 ios_base::iostate __err = ios_base::goodbit;
1077 typename traits_type::int_type __i = this->rdbuf()->sgetc();
1078 if (traits_type::eq_int_type(__i, traits_type::eof()))
1080 __err |= ios_base::eofbit;
1083 char_type __ch = traits_type::to_char_type(__i);
1084 if (traits_type::eq(__ch, __dlm))
1086 this->rdbuf()->sbumpc();
1092 __err |= ios_base::failbit;
1096 this->rdbuf()->sbumpc();
1102 __err |= ios_base::failbit;
1103 this->setstate(__err);
1105 #ifndef _LIBCPP_NO_EXCEPTIONS
1109 this->__set_badbit_and_consider_rethrow();
1111 #endif // _LIBCPP_NO_EXCEPTIONS
1115 template<class _CharT, class _Traits>
1116 inline _LIBCPP_INLINE_VISIBILITY
1117 basic_istream<_CharT, _Traits>&
1118 basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n)
1120 return getline(__s, __n, this->widen('\n'));
1123 template<class _CharT, class _Traits>
1124 basic_istream<_CharT, _Traits>&
1125 basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
1128 #ifndef _LIBCPP_NO_EXCEPTIONS
1131 #endif // _LIBCPP_NO_EXCEPTIONS
1132 sentry __sen(*this, true);
1135 ios_base::iostate __err = ios_base::goodbit;
1136 if (__n == numeric_limits<streamsize>::max())
1140 typename traits_type::int_type __i = this->rdbuf()->sbumpc();
1141 if (traits_type::eq_int_type(__i, traits_type::eof()))
1143 __err |= ios_base::eofbit;
1147 if (traits_type::eq_int_type(__i, __dlm))
1155 typename traits_type::int_type __i = this->rdbuf()->sbumpc();
1156 if (traits_type::eq_int_type(__i, traits_type::eof()))
1158 __err |= ios_base::eofbit;
1162 if (traits_type::eq_int_type(__i, __dlm))
1166 this->setstate(__err);
1168 #ifndef _LIBCPP_NO_EXCEPTIONS
1172 this->__set_badbit_and_consider_rethrow();
1174 #endif // _LIBCPP_NO_EXCEPTIONS
1178 template<class _CharT, class _Traits>
1179 typename basic_istream<_CharT, _Traits>::int_type
1180 basic_istream<_CharT, _Traits>::peek()
1183 int_type __r = traits_type::eof();
1184 #ifndef _LIBCPP_NO_EXCEPTIONS
1187 #endif // _LIBCPP_NO_EXCEPTIONS
1188 sentry __sen(*this, true);
1191 __r = this->rdbuf()->sgetc();
1192 if (traits_type::eq_int_type(__r, traits_type::eof()))
1193 this->setstate(ios_base::eofbit);
1195 #ifndef _LIBCPP_NO_EXCEPTIONS
1199 this->__set_badbit_and_consider_rethrow();
1201 #endif // _LIBCPP_NO_EXCEPTIONS
1205 template<class _CharT, class _Traits>
1206 basic_istream<_CharT, _Traits>&
1207 basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
1210 #ifndef _LIBCPP_NO_EXCEPTIONS
1213 #endif // _LIBCPP_NO_EXCEPTIONS
1214 sentry __sen(*this, true);
1217 __gc_ = this->rdbuf()->sgetn(__s, __n);
1219 this->setstate(ios_base::failbit | ios_base::eofbit);
1222 this->setstate(ios_base::failbit);
1223 #ifndef _LIBCPP_NO_EXCEPTIONS
1227 this->__set_badbit_and_consider_rethrow();
1229 #endif // _LIBCPP_NO_EXCEPTIONS
1233 template<class _CharT, class _Traits>
1235 basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
1238 streamsize __c = this->rdbuf()->in_avail();
1242 this->setstate(ios_base::eofbit);
1247 read(__s, _VSTD::min(__c, __n));
1253 template<class _CharT, class _Traits>
1254 basic_istream<_CharT, _Traits>&
1255 basic_istream<_CharT, _Traits>::putback(char_type __c)
1258 #ifndef _LIBCPP_NO_EXCEPTIONS
1261 #endif // _LIBCPP_NO_EXCEPTIONS
1262 this->clear(this->rdstate() & ~ios_base::eofbit);
1263 sentry __sen(*this, true);
1266 if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof())
1267 this->setstate(ios_base::badbit);
1270 this->setstate(ios_base::failbit);
1271 #ifndef _LIBCPP_NO_EXCEPTIONS
1275 this->__set_badbit_and_consider_rethrow();
1277 #endif // _LIBCPP_NO_EXCEPTIONS
1281 template<class _CharT, class _Traits>
1282 basic_istream<_CharT, _Traits>&
1283 basic_istream<_CharT, _Traits>::unget()
1286 #ifndef _LIBCPP_NO_EXCEPTIONS
1289 #endif // _LIBCPP_NO_EXCEPTIONS
1290 this->clear(this->rdstate() & ~ios_base::eofbit);
1291 sentry __sen(*this, true);
1294 if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof())
1295 this->setstate(ios_base::badbit);
1298 this->setstate(ios_base::failbit);
1299 #ifndef _LIBCPP_NO_EXCEPTIONS
1303 this->__set_badbit_and_consider_rethrow();
1305 #endif // _LIBCPP_NO_EXCEPTIONS
1309 template<class _CharT, class _Traits>
1311 basic_istream<_CharT, _Traits>::sync()
1314 #ifndef _LIBCPP_NO_EXCEPTIONS
1317 #endif // _LIBCPP_NO_EXCEPTIONS
1318 sentry __sen(*this, true);
1321 if (this->rdbuf() == 0)
1323 if (this->rdbuf()->pubsync() == -1)
1325 this->setstate(ios_base::badbit);
1329 #ifndef _LIBCPP_NO_EXCEPTIONS
1333 this->__set_badbit_and_consider_rethrow();
1335 #endif // _LIBCPP_NO_EXCEPTIONS
1339 template<class _CharT, class _Traits>
1340 typename basic_istream<_CharT, _Traits>::pos_type
1341 basic_istream<_CharT, _Traits>::tellg()
1344 #ifndef _LIBCPP_NO_EXCEPTIONS
1347 #endif // _LIBCPP_NO_EXCEPTIONS
1348 sentry __sen(*this, true);
1350 __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
1351 #ifndef _LIBCPP_NO_EXCEPTIONS
1355 this->__set_badbit_and_consider_rethrow();
1357 #endif // _LIBCPP_NO_EXCEPTIONS
1361 template<class _CharT, class _Traits>
1362 basic_istream<_CharT, _Traits>&
1363 basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
1365 #ifndef _LIBCPP_NO_EXCEPTIONS
1368 #endif // _LIBCPP_NO_EXCEPTIONS
1369 this->clear(this->rdstate() & ~ios_base::eofbit);
1370 sentry __sen(*this, true);
1372 if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
1373 this->setstate(ios_base::failbit);
1374 #ifndef _LIBCPP_NO_EXCEPTIONS
1378 this->__set_badbit_and_consider_rethrow();
1380 #endif // _LIBCPP_NO_EXCEPTIONS
1384 template<class _CharT, class _Traits>
1385 basic_istream<_CharT, _Traits>&
1386 basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
1388 #ifndef _LIBCPP_NO_EXCEPTIONS
1391 #endif // _LIBCPP_NO_EXCEPTIONS
1392 sentry __sen(*this, true);
1394 this->rdbuf()->pubseekoff(__off, __dir, ios_base::in);
1395 #ifndef _LIBCPP_NO_EXCEPTIONS
1399 this->__set_badbit_and_consider_rethrow();
1401 #endif // _LIBCPP_NO_EXCEPTIONS
1405 template <class _CharT, class _Traits>
1406 basic_istream<_CharT, _Traits>&
1407 ws(basic_istream<_CharT, _Traits>& __is)
1409 #ifndef _LIBCPP_NO_EXCEPTIONS
1412 #endif // _LIBCPP_NO_EXCEPTIONS
1413 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1416 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1419 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
1420 if (_Traits::eq_int_type(__i, _Traits::eof()))
1422 __is.setstate(ios_base::eofbit);
1425 if (!__ct.is(__ct.space, _Traits::to_char_type(__i)))
1427 __is.rdbuf()->sbumpc();
1430 #ifndef _LIBCPP_NO_EXCEPTIONS
1434 __is.__set_badbit_and_consider_rethrow();
1436 #endif // _LIBCPP_NO_EXCEPTIONS
1440 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1442 template <class _CharT, class _Traits, class _Tp>
1443 inline _LIBCPP_INLINE_VISIBILITY
1444 basic_istream<_CharT, _Traits>&
1445 operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
1451 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1453 template <class _CharT, class _Traits>
1454 class _LIBCPP_TYPE_VIS basic_iostream
1455 : public basic_istream<_CharT, _Traits>,
1456 public basic_ostream<_CharT, _Traits>
1460 typedef _CharT char_type;
1461 typedef _Traits traits_type;
1462 typedef typename traits_type::int_type int_type;
1463 typedef typename traits_type::pos_type pos_type;
1464 typedef typename traits_type::off_type off_type;
1466 // constructor/destructor
1467 explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb);
1468 virtual ~basic_iostream();
1470 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1471 _LIBCPP_INLINE_VISIBILITY
1472 basic_iostream(basic_iostream&& __rhs);
1476 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1477 _LIBCPP_INLINE_VISIBILITY
1478 basic_iostream& operator=(basic_iostream&& __rhs);
1480 void swap(basic_iostream& __rhs);
1484 template <class _CharT, class _Traits>
1485 inline _LIBCPP_INLINE_VISIBILITY
1486 basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
1487 : basic_istream<_CharT, _Traits>(__sb)
1491 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1493 template <class _CharT, class _Traits>
1494 inline _LIBCPP_INLINE_VISIBILITY
1495 basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
1496 : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
1500 template <class _CharT, class _Traits>
1501 inline _LIBCPP_INLINE_VISIBILITY
1502 basic_iostream<_CharT, _Traits>&
1503 basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
1509 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1511 template <class _CharT, class _Traits>
1512 basic_iostream<_CharT, _Traits>::~basic_iostream()
1516 template <class _CharT, class _Traits>
1517 inline _LIBCPP_INLINE_VISIBILITY
1519 basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs)
1521 basic_istream<char_type, traits_type>::swap(__rhs);
1524 template<class _CharT, class _Traits, class _Allocator>
1525 basic_istream<_CharT, _Traits>&
1526 operator>>(basic_istream<_CharT, _Traits>& __is,
1527 basic_string<_CharT, _Traits, _Allocator>& __str)
1529 #ifndef _LIBCPP_NO_EXCEPTIONS
1532 #endif // _LIBCPP_NO_EXCEPTIONS
1533 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
1537 streamsize __n = __is.width();
1539 __n = __str.max_size();
1541 __n = numeric_limits<streamsize>::max();
1543 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1544 ios_base::iostate __err = ios_base::goodbit;
1547 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
1548 if (_Traits::eq_int_type(__i, _Traits::eof()))
1550 __err |= ios_base::eofbit;
1553 _CharT __ch = _Traits::to_char_type(__i);
1554 if (__ct.is(__ct.space, __ch))
1556 __str.push_back(__ch);
1558 __is.rdbuf()->sbumpc();
1562 __err |= ios_base::failbit;
1563 __is.setstate(__err);
1566 __is.setstate(ios_base::failbit);
1567 #ifndef _LIBCPP_NO_EXCEPTIONS
1571 __is.__set_badbit_and_consider_rethrow();
1573 #endif // _LIBCPP_NO_EXCEPTIONS
1577 template<class _CharT, class _Traits, class _Allocator>
1578 basic_istream<_CharT, _Traits>&
1579 getline(basic_istream<_CharT, _Traits>& __is,
1580 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
1582 #ifndef _LIBCPP_NO_EXCEPTIONS
1585 #endif // _LIBCPP_NO_EXCEPTIONS
1586 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1590 ios_base::iostate __err = ios_base::goodbit;
1591 streamsize __extr = 0;
1594 typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
1595 if (_Traits::eq_int_type(__i, _Traits::eof()))
1597 __err |= ios_base::eofbit;
1601 _CharT __ch = _Traits::to_char_type(__i);
1602 if (_Traits::eq(__ch, __dlm))
1604 __str.push_back(__ch);
1605 if (__str.size() == __str.max_size())
1607 __err |= ios_base::failbit;
1612 __err |= ios_base::failbit;
1613 __is.setstate(__err);
1615 #ifndef _LIBCPP_NO_EXCEPTIONS
1619 __is.__set_badbit_and_consider_rethrow();
1621 #endif // _LIBCPP_NO_EXCEPTIONS
1625 template<class _CharT, class _Traits, class _Allocator>
1626 inline _LIBCPP_INLINE_VISIBILITY
1627 basic_istream<_CharT, _Traits>&
1628 getline(basic_istream<_CharT, _Traits>& __is,
1629 basic_string<_CharT, _Traits, _Allocator>& __str)
1631 return getline(__is, __str, __is.widen('\n'));
1634 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1636 template<class _CharT, class _Traits, class _Allocator>
1637 inline _LIBCPP_INLINE_VISIBILITY
1638 basic_istream<_CharT, _Traits>&
1639 getline(basic_istream<_CharT, _Traits>&& __is,
1640 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
1642 return getline(__is, __str, __dlm);
1645 template<class _CharT, class _Traits, class _Allocator>
1646 inline _LIBCPP_INLINE_VISIBILITY
1647 basic_istream<_CharT, _Traits>&
1648 getline(basic_istream<_CharT, _Traits>&& __is,
1649 basic_string<_CharT, _Traits, _Allocator>& __str)
1651 return getline(__is, __str, __is.widen('\n'));
1654 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1656 template <class _CharT, class _Traits, size_t _Size>
1657 basic_istream<_CharT, _Traits>&
1658 operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
1660 #ifndef _LIBCPP_NO_EXCEPTIONS
1663 #endif // _LIBCPP_NO_EXCEPTIONS
1664 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
1667 basic_string<_CharT, _Traits> __str;
1668 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1670 ios_base::iostate __err = ios_base::goodbit;
1671 _CharT __zero = __ct.widen('0');
1672 _CharT __one = __ct.widen('1');
1675 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
1676 if (_Traits::eq_int_type(__i, _Traits::eof()))
1678 __err |= ios_base::eofbit;
1681 _CharT __ch = _Traits::to_char_type(__i);
1682 if (!_Traits::eq(__ch, __zero) && !_Traits::eq(__ch, __one))
1684 __str.push_back(__ch);
1686 __is.rdbuf()->sbumpc();
1688 __x = bitset<_Size>(__str);
1690 __err |= ios_base::failbit;
1691 __is.setstate(__err);
1694 __is.setstate(ios_base::failbit);
1695 #ifndef _LIBCPP_NO_EXCEPTIONS
1699 __is.__set_badbit_and_consider_rethrow();
1701 #endif // _LIBCPP_NO_EXCEPTIONS
1705 _LIBCPP_EXTERN_TEMPLATE(class basic_istream<char>)
1706 _LIBCPP_EXTERN_TEMPLATE(class basic_istream<wchar_t>)
1707 _LIBCPP_EXTERN_TEMPLATE(class basic_iostream<char>)
1709 _LIBCPP_END_NAMESPACE_STD
1711 #endif // _LIBCPP_ISTREAM