14684ddb6SLionel Sambuc// -*- C++ -*- 24684ddb6SLionel Sambuc//===--------------------------- istream ----------------------------------===// 34684ddb6SLionel Sambuc// 44684ddb6SLionel Sambuc// The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc// 64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open 74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc// 94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuc#ifndef _LIBCPP_ISTREAM 124684ddb6SLionel Sambuc#define _LIBCPP_ISTREAM 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc/* 154684ddb6SLionel Sambuc istream synopsis 164684ddb6SLionel Sambuc 174684ddb6SLionel Sambuctemplate <class charT, class traits = char_traits<charT> > 184684ddb6SLionel Sambucclass basic_istream 194684ddb6SLionel Sambuc : virtual public basic_ios<charT,traits> 204684ddb6SLionel Sambuc{ 214684ddb6SLionel Sambucpublic: 224684ddb6SLionel Sambuc // types (inherited from basic_ios (27.5.4)): 234684ddb6SLionel Sambuc typedef charT char_type; 244684ddb6SLionel Sambuc typedef traits traits_type; 254684ddb6SLionel Sambuc typedef typename traits_type::int_type int_type; 264684ddb6SLionel Sambuc typedef typename traits_type::pos_type pos_type; 274684ddb6SLionel Sambuc typedef typename traits_type::off_type off_type; 284684ddb6SLionel Sambuc 294684ddb6SLionel Sambuc // 27.7.1.1.1 Constructor/destructor: 304684ddb6SLionel Sambuc explicit basic_istream(basic_streambuf<char_type, traits_type>* sb); 314684ddb6SLionel Sambuc basic_istream(basic_istream&& rhs); 324684ddb6SLionel Sambuc virtual ~basic_istream(); 334684ddb6SLionel Sambuc 344684ddb6SLionel Sambuc // 27.7.1.1.2 Assign/swap: 354684ddb6SLionel Sambuc basic_istream& operator=(basic_istream&& rhs); 364684ddb6SLionel Sambuc void swap(basic_istream& rhs); 374684ddb6SLionel Sambuc 384684ddb6SLionel Sambuc // 27.7.1.1.3 Prefix/suffix: 394684ddb6SLionel Sambuc class sentry; 404684ddb6SLionel Sambuc 414684ddb6SLionel Sambuc // 27.7.1.2 Formatted input: 424684ddb6SLionel Sambuc basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); 434684ddb6SLionel Sambuc basic_istream& operator>>(basic_ios<char_type, traits_type>& 444684ddb6SLionel Sambuc (*pf)(basic_ios<char_type, traits_type>&)); 454684ddb6SLionel Sambuc basic_istream& operator>>(ios_base& (*pf)(ios_base&)); 464684ddb6SLionel Sambuc basic_istream& operator>>(basic_streambuf<char_type, traits_type>* sb); 474684ddb6SLionel Sambuc basic_istream& operator>>(bool& n); 484684ddb6SLionel Sambuc basic_istream& operator>>(short& n); 494684ddb6SLionel Sambuc basic_istream& operator>>(unsigned short& n); 504684ddb6SLionel Sambuc basic_istream& operator>>(int& n); 514684ddb6SLionel Sambuc basic_istream& operator>>(unsigned int& n); 524684ddb6SLionel Sambuc basic_istream& operator>>(long& n); 534684ddb6SLionel Sambuc basic_istream& operator>>(unsigned long& n); 544684ddb6SLionel Sambuc basic_istream& operator>>(long long& n); 554684ddb6SLionel Sambuc basic_istream& operator>>(unsigned long long& n); 564684ddb6SLionel Sambuc basic_istream& operator>>(float& f); 574684ddb6SLionel Sambuc basic_istream& operator>>(double& f); 584684ddb6SLionel Sambuc basic_istream& operator>>(long double& f); 594684ddb6SLionel Sambuc basic_istream& operator>>(void*& p); 604684ddb6SLionel Sambuc 614684ddb6SLionel Sambuc // 27.7.1.3 Unformatted input: 624684ddb6SLionel Sambuc streamsize gcount() const; 634684ddb6SLionel Sambuc int_type get(); 644684ddb6SLionel Sambuc basic_istream& get(char_type& c); 654684ddb6SLionel Sambuc basic_istream& get(char_type* s, streamsize n); 664684ddb6SLionel Sambuc basic_istream& get(char_type* s, streamsize n, char_type delim); 674684ddb6SLionel Sambuc basic_istream& get(basic_streambuf<char_type,traits_type>& sb); 684684ddb6SLionel Sambuc basic_istream& get(basic_streambuf<char_type,traits_type>& sb, char_type delim); 694684ddb6SLionel Sambuc 704684ddb6SLionel Sambuc basic_istream& getline(char_type* s, streamsize n); 714684ddb6SLionel Sambuc basic_istream& getline(char_type* s, streamsize n, char_type delim); 724684ddb6SLionel Sambuc 734684ddb6SLionel Sambuc basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof()); 744684ddb6SLionel Sambuc int_type peek(); 754684ddb6SLionel Sambuc basic_istream& read (char_type* s, streamsize n); 764684ddb6SLionel Sambuc streamsize readsome(char_type* s, streamsize n); 774684ddb6SLionel Sambuc 784684ddb6SLionel Sambuc basic_istream& putback(char_type c); 794684ddb6SLionel Sambuc basic_istream& unget(); 804684ddb6SLionel Sambuc int sync(); 814684ddb6SLionel Sambuc 824684ddb6SLionel Sambuc pos_type tellg(); 834684ddb6SLionel Sambuc basic_istream& seekg(pos_type); 844684ddb6SLionel Sambuc basic_istream& seekg(off_type, ios_base::seekdir); 85*0a6a1f1dSLionel Sambucprotected: 86*0a6a1f1dSLionel Sambuc basic_istream(const basic_istream& rhs) = delete; 87*0a6a1f1dSLionel Sambuc basic_istream(basic_istream&& rhs); 88*0a6a1f1dSLionel Sambuc // 27.7.2.1.2 Assign/swap: 89*0a6a1f1dSLionel Sambuc basic_istream& operator=(const basic_istream& rhs) = delete; 90*0a6a1f1dSLionel Sambuc basic_istream& operator=(basic_istream&& rhs); 91*0a6a1f1dSLionel Sambuc void swap(basic_istream& rhs); 924684ddb6SLionel Sambuc}; 934684ddb6SLionel Sambuc 944684ddb6SLionel Sambuc// 27.7.1.2.3 character extraction templates: 954684ddb6SLionel Sambuctemplate<class charT, class traits> 964684ddb6SLionel Sambuc basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT&); 974684ddb6SLionel Sambuc 984684ddb6SLionel Sambuctemplate<class traits> 994684ddb6SLionel Sambuc basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char&); 1004684ddb6SLionel Sambuc 1014684ddb6SLionel Sambuctemplate<class traits> 1024684ddb6SLionel Sambuc basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char&); 1034684ddb6SLionel Sambuc 1044684ddb6SLionel Sambuctemplate<class charT, class traits> 1054684ddb6SLionel Sambuc basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT*); 1064684ddb6SLionel Sambuc 1074684ddb6SLionel Sambuctemplate<class traits> 1084684ddb6SLionel Sambuc basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char*); 1094684ddb6SLionel Sambuc 1104684ddb6SLionel Sambuctemplate<class traits> 1114684ddb6SLionel Sambuc basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char*); 1124684ddb6SLionel Sambuc 1134684ddb6SLionel Sambuctemplate <class charT, class traits> 1144684ddb6SLionel Sambuc void 1154684ddb6SLionel Sambuc swap(basic_istream<charT, traits>& x, basic_istream<charT, traits>& y); 1164684ddb6SLionel Sambuc 1174684ddb6SLionel Sambuctypedef basic_istream<char> istream; 1184684ddb6SLionel Sambuctypedef basic_istream<wchar_t> wistream; 1194684ddb6SLionel Sambuc 1204684ddb6SLionel Sambuctemplate <class charT, class traits = char_traits<charT> > 1214684ddb6SLionel Sambucclass basic_iostream : 1224684ddb6SLionel Sambuc public basic_istream<charT,traits>, 1234684ddb6SLionel Sambuc public basic_ostream<charT,traits> 1244684ddb6SLionel Sambuc{ 1254684ddb6SLionel Sambucpublic: 1264684ddb6SLionel Sambuc // types: 1274684ddb6SLionel Sambuc typedef charT char_type; 1284684ddb6SLionel Sambuc typedef traits traits_type; 1294684ddb6SLionel Sambuc typedef typename traits_type::int_type int_type; 1304684ddb6SLionel Sambuc typedef typename traits_type::pos_type pos_type; 1314684ddb6SLionel Sambuc typedef typename traits_type::off_type off_type; 1324684ddb6SLionel Sambuc 1334684ddb6SLionel Sambuc // constructor/destructor 1344684ddb6SLionel Sambuc explicit basic_iostream(basic_streambuf<char_type, traits_type>* sb); 1354684ddb6SLionel Sambuc basic_iostream(basic_iostream&& rhs); 1364684ddb6SLionel Sambuc virtual ~basic_iostream(); 1374684ddb6SLionel Sambuc 1384684ddb6SLionel Sambuc // assign/swap 1394684ddb6SLionel Sambuc basic_iostream& operator=(basic_iostream&& rhs); 1404684ddb6SLionel Sambuc void swap(basic_iostream& rhs); 1414684ddb6SLionel Sambuc}; 1424684ddb6SLionel Sambuc 1434684ddb6SLionel Sambuctemplate <class charT, class traits> 1444684ddb6SLionel Sambuc void 1454684ddb6SLionel Sambuc swap(basic_iostream<charT, traits>& x, basic_iostream<charT, traits>& y); 1464684ddb6SLionel Sambuc 1474684ddb6SLionel Sambuctypedef basic_iostream<char> iostream; 1484684ddb6SLionel Sambuctypedef basic_iostream<wchar_t> wiostream; 1494684ddb6SLionel Sambuc 1504684ddb6SLionel Sambuctemplate <class charT, class traits> 1514684ddb6SLionel Sambuc basic_istream<charT,traits>& 1524684ddb6SLionel Sambuc ws(basic_istream<charT,traits>& is); 1534684ddb6SLionel Sambuc 1544684ddb6SLionel Sambuctemplate <class charT, class traits, class T> 1554684ddb6SLionel Sambuc basic_istream<charT, traits>& 1564684ddb6SLionel Sambuc operator>>(basic_istream<charT, traits>&& is, T& x); 1574684ddb6SLionel Sambuc 1584684ddb6SLionel Sambuc} // std 1594684ddb6SLionel Sambuc 1604684ddb6SLionel Sambuc*/ 1614684ddb6SLionel Sambuc 1624684ddb6SLionel Sambuc#include <__config> 1634684ddb6SLionel Sambuc#include <ostream> 1644684ddb6SLionel Sambuc 1654684ddb6SLionel Sambuc#include <__undef_min_max> 1664684ddb6SLionel Sambuc 1674684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1684684ddb6SLionel Sambuc#pragma GCC system_header 1694684ddb6SLionel Sambuc#endif 1704684ddb6SLionel Sambuc 1714684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD 1724684ddb6SLionel Sambuc 1734684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 1744684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY basic_istream 1754684ddb6SLionel Sambuc : virtual public basic_ios<_CharT, _Traits> 1764684ddb6SLionel Sambuc{ 1774684ddb6SLionel Sambuc streamsize __gc_; 1784684ddb6SLionel Sambucpublic: 1794684ddb6SLionel Sambuc // types (inherited from basic_ios (27.5.4)): 1804684ddb6SLionel Sambuc typedef _CharT char_type; 1814684ddb6SLionel Sambuc typedef _Traits traits_type; 1824684ddb6SLionel Sambuc typedef typename traits_type::int_type int_type; 1834684ddb6SLionel Sambuc typedef typename traits_type::pos_type pos_type; 1844684ddb6SLionel Sambuc typedef typename traits_type::off_type off_type; 1854684ddb6SLionel Sambuc 1864684ddb6SLionel Sambuc // 27.7.1.1.1 Constructor/destructor: 1874684ddb6SLionel Sambuc explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb); 1884684ddb6SLionel Sambuc virtual ~basic_istream(); 1894684ddb6SLionel Sambucprotected: 1904684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1914684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1924684ddb6SLionel Sambuc basic_istream(basic_istream&& __rhs); 1934684ddb6SLionel Sambuc#endif 1944684ddb6SLionel Sambuc // 27.7.1.1.2 Assign/swap: 1954684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1964684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1974684ddb6SLionel Sambuc basic_istream& operator=(basic_istream&& __rhs); 1984684ddb6SLionel Sambuc#endif 1994684ddb6SLionel Sambuc void swap(basic_istream& __rhs); 200*0a6a1f1dSLionel Sambuc 201*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 11 202*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS 203*0a6a1f1dSLionel Sambuc basic_istream (const basic_istream& __rhs) = delete; 204*0a6a1f1dSLionel Sambuc basic_istream& operator=(const basic_istream& __rhs) = delete; 205*0a6a1f1dSLionel Sambuc#else 206*0a6a1f1dSLionel Sambuc basic_istream (const basic_istream& __rhs); // not defined 207*0a6a1f1dSLionel Sambuc basic_istream& operator=(const basic_istream& __rhs); // not defined 208*0a6a1f1dSLionel Sambuc#endif 209*0a6a1f1dSLionel Sambuc#endif 2104684ddb6SLionel Sambucpublic: 2114684ddb6SLionel Sambuc 2124684ddb6SLionel Sambuc // 27.7.1.1.3 Prefix/suffix: 2134684ddb6SLionel Sambuc class _LIBCPP_TYPE_VIS_ONLY sentry; 2144684ddb6SLionel Sambuc 2154684ddb6SLionel Sambuc // 27.7.1.2 Formatted input: 2164684ddb6SLionel Sambuc basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)); 2174684ddb6SLionel Sambuc basic_istream& operator>>(basic_ios<char_type, traits_type>& 2184684ddb6SLionel Sambuc (*__pf)(basic_ios<char_type, traits_type>&)); 2194684ddb6SLionel Sambuc basic_istream& operator>>(ios_base& (*__pf)(ios_base&)); 2204684ddb6SLionel Sambuc basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb); 2214684ddb6SLionel Sambuc basic_istream& operator>>(bool& __n); 2224684ddb6SLionel Sambuc basic_istream& operator>>(short& __n); 2234684ddb6SLionel Sambuc basic_istream& operator>>(unsigned short& __n); 2244684ddb6SLionel Sambuc basic_istream& operator>>(int& __n); 2254684ddb6SLionel Sambuc basic_istream& operator>>(unsigned int& __n); 2264684ddb6SLionel Sambuc basic_istream& operator>>(long& __n); 2274684ddb6SLionel Sambuc basic_istream& operator>>(unsigned long& __n); 2284684ddb6SLionel Sambuc basic_istream& operator>>(long long& __n); 2294684ddb6SLionel Sambuc basic_istream& operator>>(unsigned long long& __n); 2304684ddb6SLionel Sambuc basic_istream& operator>>(float& __f); 2314684ddb6SLionel Sambuc basic_istream& operator>>(double& __f); 2324684ddb6SLionel Sambuc basic_istream& operator>>(long double& __f); 2334684ddb6SLionel Sambuc basic_istream& operator>>(void*& __p); 2344684ddb6SLionel Sambuc 2354684ddb6SLionel Sambuc // 27.7.1.3 Unformatted input: 2364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2374684ddb6SLionel Sambuc streamsize gcount() const {return __gc_;} 2384684ddb6SLionel Sambuc int_type get(); 2394684ddb6SLionel Sambuc basic_istream& get(char_type& __c); 2404684ddb6SLionel Sambuc basic_istream& get(char_type* __s, streamsize __n); 2414684ddb6SLionel Sambuc basic_istream& get(char_type* __s, streamsize __n, char_type __dlm); 2424684ddb6SLionel Sambuc basic_istream& get(basic_streambuf<char_type, traits_type>& __sb); 2434684ddb6SLionel Sambuc basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm); 2444684ddb6SLionel Sambuc 2454684ddb6SLionel Sambuc basic_istream& getline(char_type* __s, streamsize __n); 2464684ddb6SLionel Sambuc basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm); 2474684ddb6SLionel Sambuc 2484684ddb6SLionel Sambuc basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof()); 2494684ddb6SLionel Sambuc int_type peek(); 2504684ddb6SLionel Sambuc basic_istream& read (char_type* __s, streamsize __n); 2514684ddb6SLionel Sambuc streamsize readsome(char_type* __s, streamsize __n); 2524684ddb6SLionel Sambuc 2534684ddb6SLionel Sambuc basic_istream& putback(char_type __c); 2544684ddb6SLionel Sambuc basic_istream& unget(); 2554684ddb6SLionel Sambuc int sync(); 2564684ddb6SLionel Sambuc 2574684ddb6SLionel Sambuc pos_type tellg(); 2584684ddb6SLionel Sambuc basic_istream& seekg(pos_type __pos); 2594684ddb6SLionel Sambuc basic_istream& seekg(off_type __off, ios_base::seekdir __dir); 2604684ddb6SLionel Sambuc}; 2614684ddb6SLionel Sambuc 2624684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 2634684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY basic_istream<_CharT, _Traits>::sentry 2644684ddb6SLionel Sambuc{ 2654684ddb6SLionel Sambuc bool __ok_; 2664684ddb6SLionel Sambuc 2674684ddb6SLionel Sambuc sentry(const sentry&); // = delete; 2684684ddb6SLionel Sambuc sentry& operator=(const sentry&); // = delete; 2694684ddb6SLionel Sambuc 2704684ddb6SLionel Sambucpublic: 2714684ddb6SLionel Sambuc explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); 2724684ddb6SLionel Sambuc// ~sentry() = default; 2734684ddb6SLionel Sambuc 2744684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2754684ddb6SLionel Sambuc _LIBCPP_EXPLICIT 2764684ddb6SLionel Sambuc operator bool() const {return __ok_;} 2774684ddb6SLionel Sambuc}; 2784684ddb6SLionel Sambuc 2794684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 2804684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is, 2814684ddb6SLionel Sambuc bool __noskipws) 2824684ddb6SLionel Sambuc : __ok_(false) 2834684ddb6SLionel Sambuc{ 2844684ddb6SLionel Sambuc if (__is.good()) 2854684ddb6SLionel Sambuc { 2864684ddb6SLionel Sambuc if (__is.tie()) 2874684ddb6SLionel Sambuc __is.tie()->flush(); 2884684ddb6SLionel Sambuc if (!__noskipws && (__is.flags() & ios_base::skipws)) 2894684ddb6SLionel Sambuc { 2904684ddb6SLionel Sambuc typedef istreambuf_iterator<_CharT, _Traits> _Ip; 2914684ddb6SLionel Sambuc const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); 2924684ddb6SLionel Sambuc _Ip __i(__is); 2934684ddb6SLionel Sambuc _Ip __eof; 2944684ddb6SLionel Sambuc for (; __i != __eof; ++__i) 2954684ddb6SLionel Sambuc if (!__ct.is(__ct.space, *__i)) 2964684ddb6SLionel Sambuc break; 2974684ddb6SLionel Sambuc if (__i == __eof) 2984684ddb6SLionel Sambuc __is.setstate(ios_base::failbit | ios_base::eofbit); 2994684ddb6SLionel Sambuc } 3004684ddb6SLionel Sambuc __ok_ = __is.good(); 3014684ddb6SLionel Sambuc } 3024684ddb6SLionel Sambuc else 3034684ddb6SLionel Sambuc __is.setstate(ios_base::failbit); 3044684ddb6SLionel Sambuc} 3054684ddb6SLionel Sambuc 3064684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 3074684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3084684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::basic_istream(basic_streambuf<char_type, traits_type>* __sb) 3094684ddb6SLionel Sambuc : __gc_(0) 3104684ddb6SLionel Sambuc{ 3114684ddb6SLionel Sambuc this->init(__sb); 3124684ddb6SLionel Sambuc} 3134684ddb6SLionel Sambuc 3144684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3154684ddb6SLionel Sambuc 3164684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 3174684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3184684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) 3194684ddb6SLionel Sambuc : __gc_(__rhs.__gc_) 3204684ddb6SLionel Sambuc{ 3214684ddb6SLionel Sambuc __rhs.__gc_ = 0; 3224684ddb6SLionel Sambuc this->move(__rhs); 3234684ddb6SLionel Sambuc} 3244684ddb6SLionel Sambuc 3254684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 3264684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3274684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 3284684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs) 3294684ddb6SLionel Sambuc{ 3304684ddb6SLionel Sambuc swap(__rhs); 3314684ddb6SLionel Sambuc return *this; 3324684ddb6SLionel Sambuc} 3334684ddb6SLionel Sambuc 3344684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3354684ddb6SLionel Sambuc 3364684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 3374684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::~basic_istream() 3384684ddb6SLionel Sambuc{ 3394684ddb6SLionel Sambuc} 3404684ddb6SLionel Sambuc 3414684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 3424684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3434684ddb6SLionel Sambucvoid 3444684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::swap(basic_istream& __rhs) 3454684ddb6SLionel Sambuc{ 3464684ddb6SLionel Sambuc _VSTD::swap(__gc_, __rhs.__gc_); 3474684ddb6SLionel Sambuc basic_ios<char_type, traits_type>::swap(__rhs); 3484684ddb6SLionel Sambuc} 3494684ddb6SLionel Sambuc 3504684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 3514684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 3524684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(unsigned short& __n) 3534684ddb6SLionel Sambuc{ 3544684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3554684ddb6SLionel Sambuc try 3564684ddb6SLionel Sambuc { 3574684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 3584684ddb6SLionel Sambuc sentry __s(*this); 3594684ddb6SLionel Sambuc if (__s) 3604684ddb6SLionel Sambuc { 3614684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 3624684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 3634684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 3644684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 3654684ddb6SLionel Sambuc this->setstate(__err); 3664684ddb6SLionel Sambuc } 3674684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3684684ddb6SLionel Sambuc } 3694684ddb6SLionel Sambuc catch (...) 3704684ddb6SLionel Sambuc { 3714684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 3724684ddb6SLionel Sambuc } 3734684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 3744684ddb6SLionel Sambuc return *this; 3754684ddb6SLionel Sambuc} 3764684ddb6SLionel Sambuc 3774684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 3784684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 3794684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(unsigned int& __n) 3804684ddb6SLionel Sambuc{ 3814684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3824684ddb6SLionel Sambuc try 3834684ddb6SLionel Sambuc { 3844684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 3854684ddb6SLionel Sambuc sentry __s(*this); 3864684ddb6SLionel Sambuc if (__s) 3874684ddb6SLionel Sambuc { 3884684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 3894684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 3904684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 3914684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 3924684ddb6SLionel Sambuc this->setstate(__err); 3934684ddb6SLionel Sambuc } 3944684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3954684ddb6SLionel Sambuc } 3964684ddb6SLionel Sambuc catch (...) 3974684ddb6SLionel Sambuc { 3984684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 3994684ddb6SLionel Sambuc } 4004684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4014684ddb6SLionel Sambuc return *this; 4024684ddb6SLionel Sambuc} 4034684ddb6SLionel Sambuc 4044684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 4054684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 4064684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(long& __n) 4074684ddb6SLionel Sambuc{ 4084684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4094684ddb6SLionel Sambuc try 4104684ddb6SLionel Sambuc { 4114684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4124684ddb6SLionel Sambuc sentry __s(*this); 4134684ddb6SLionel Sambuc if (__s) 4144684ddb6SLionel Sambuc { 4154684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 4164684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 4174684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 4184684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 4194684ddb6SLionel Sambuc this->setstate(__err); 4204684ddb6SLionel Sambuc } 4214684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4224684ddb6SLionel Sambuc } 4234684ddb6SLionel Sambuc catch (...) 4244684ddb6SLionel Sambuc { 4254684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 4264684ddb6SLionel Sambuc } 4274684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4284684ddb6SLionel Sambuc return *this; 4294684ddb6SLionel Sambuc} 4304684ddb6SLionel Sambuc 4314684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 4324684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 4334684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(unsigned long& __n) 4344684ddb6SLionel Sambuc{ 4354684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4364684ddb6SLionel Sambuc try 4374684ddb6SLionel Sambuc { 4384684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4394684ddb6SLionel Sambuc sentry __s(*this); 4404684ddb6SLionel Sambuc if (__s) 4414684ddb6SLionel Sambuc { 4424684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 4434684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 4444684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 4454684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 4464684ddb6SLionel Sambuc this->setstate(__err); 4474684ddb6SLionel Sambuc } 4484684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4494684ddb6SLionel Sambuc } 4504684ddb6SLionel Sambuc catch (...) 4514684ddb6SLionel Sambuc { 4524684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 4534684ddb6SLionel Sambuc } 4544684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4554684ddb6SLionel Sambuc return *this; 4564684ddb6SLionel Sambuc} 4574684ddb6SLionel Sambuc 4584684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 4594684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 4604684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(long long& __n) 4614684ddb6SLionel Sambuc{ 4624684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4634684ddb6SLionel Sambuc try 4644684ddb6SLionel Sambuc { 4654684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4664684ddb6SLionel Sambuc sentry __s(*this); 4674684ddb6SLionel Sambuc if (__s) 4684684ddb6SLionel Sambuc { 4694684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 4704684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 4714684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 4724684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 4734684ddb6SLionel Sambuc this->setstate(__err); 4744684ddb6SLionel Sambuc } 4754684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4764684ddb6SLionel Sambuc } 4774684ddb6SLionel Sambuc catch (...) 4784684ddb6SLionel Sambuc { 4794684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 4804684ddb6SLionel Sambuc } 4814684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4824684ddb6SLionel Sambuc return *this; 4834684ddb6SLionel Sambuc} 4844684ddb6SLionel Sambuc 4854684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 4864684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 4874684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n) 4884684ddb6SLionel Sambuc{ 4894684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 4904684ddb6SLionel Sambuc try 4914684ddb6SLionel Sambuc { 4924684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 4934684ddb6SLionel Sambuc sentry __s(*this); 4944684ddb6SLionel Sambuc if (__s) 4954684ddb6SLionel Sambuc { 4964684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 4974684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 4984684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 4994684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 5004684ddb6SLionel Sambuc this->setstate(__err); 5014684ddb6SLionel Sambuc } 5024684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 5034684ddb6SLionel Sambuc } 5044684ddb6SLionel Sambuc catch (...) 5054684ddb6SLionel Sambuc { 5064684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 5074684ddb6SLionel Sambuc } 5084684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 5094684ddb6SLionel Sambuc return *this; 5104684ddb6SLionel Sambuc} 5114684ddb6SLionel Sambuc 5124684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 5134684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 5144684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(float& __n) 5154684ddb6SLionel Sambuc{ 5164684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 5174684ddb6SLionel Sambuc try 5184684ddb6SLionel Sambuc { 5194684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 5204684ddb6SLionel Sambuc sentry __s(*this); 5214684ddb6SLionel Sambuc if (__s) 5224684ddb6SLionel Sambuc { 5234684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 5244684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 5254684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 5264684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 5274684ddb6SLionel Sambuc this->setstate(__err); 5284684ddb6SLionel Sambuc } 5294684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 5304684ddb6SLionel Sambuc } 5314684ddb6SLionel Sambuc catch (...) 5324684ddb6SLionel Sambuc { 5334684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 5344684ddb6SLionel Sambuc } 5354684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 5364684ddb6SLionel Sambuc return *this; 5374684ddb6SLionel Sambuc} 5384684ddb6SLionel Sambuc 5394684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 5404684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 5414684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(double& __n) 5424684ddb6SLionel Sambuc{ 5434684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 5444684ddb6SLionel Sambuc try 5454684ddb6SLionel Sambuc { 5464684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 5474684ddb6SLionel Sambuc sentry __s(*this); 5484684ddb6SLionel Sambuc if (__s) 5494684ddb6SLionel Sambuc { 5504684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 5514684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 5524684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 5534684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 5544684ddb6SLionel Sambuc this->setstate(__err); 5554684ddb6SLionel Sambuc } 5564684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 5574684ddb6SLionel Sambuc } 5584684ddb6SLionel Sambuc catch (...) 5594684ddb6SLionel Sambuc { 5604684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 5614684ddb6SLionel Sambuc } 5624684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 5634684ddb6SLionel Sambuc return *this; 5644684ddb6SLionel Sambuc} 5654684ddb6SLionel Sambuc 5664684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 5674684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 5684684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(long double& __n) 5694684ddb6SLionel Sambuc{ 5704684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 5714684ddb6SLionel Sambuc try 5724684ddb6SLionel Sambuc { 5734684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 5744684ddb6SLionel Sambuc sentry __s(*this); 5754684ddb6SLionel Sambuc if (__s) 5764684ddb6SLionel Sambuc { 5774684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 5784684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 5794684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 5804684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 5814684ddb6SLionel Sambuc this->setstate(__err); 5824684ddb6SLionel Sambuc } 5834684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 5844684ddb6SLionel Sambuc } 5854684ddb6SLionel Sambuc catch (...) 5864684ddb6SLionel Sambuc { 5874684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 5884684ddb6SLionel Sambuc } 5894684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 5904684ddb6SLionel Sambuc return *this; 5914684ddb6SLionel Sambuc} 5924684ddb6SLionel Sambuc 5934684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 5944684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 5954684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(bool& __n) 5964684ddb6SLionel Sambuc{ 5974684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 5984684ddb6SLionel Sambuc try 5994684ddb6SLionel Sambuc { 6004684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 6014684ddb6SLionel Sambuc sentry __s(*this); 6024684ddb6SLionel Sambuc if (__s) 6034684ddb6SLionel Sambuc { 6044684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 6054684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 6064684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 6074684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 6084684ddb6SLionel Sambuc this->setstate(__err); 6094684ddb6SLionel Sambuc } 6104684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 6114684ddb6SLionel Sambuc } 6124684ddb6SLionel Sambuc catch (...) 6134684ddb6SLionel Sambuc { 6144684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 6154684ddb6SLionel Sambuc } 6164684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 6174684ddb6SLionel Sambuc return *this; 6184684ddb6SLionel Sambuc} 6194684ddb6SLionel Sambuc 6204684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 6214684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 6224684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(void*& __n) 6234684ddb6SLionel Sambuc{ 6244684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 6254684ddb6SLionel Sambuc try 6264684ddb6SLionel Sambuc { 6274684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 6284684ddb6SLionel Sambuc sentry __s(*this); 6294684ddb6SLionel Sambuc if (__s) 6304684ddb6SLionel Sambuc { 6314684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 6324684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 6334684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 6344684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); 6354684ddb6SLionel Sambuc this->setstate(__err); 6364684ddb6SLionel Sambuc } 6374684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 6384684ddb6SLionel Sambuc } 6394684ddb6SLionel Sambuc catch (...) 6404684ddb6SLionel Sambuc { 6414684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 6424684ddb6SLionel Sambuc } 6434684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 6444684ddb6SLionel Sambuc return *this; 6454684ddb6SLionel Sambuc} 6464684ddb6SLionel Sambuc 6474684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 6484684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 6494684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(short& __n) 6504684ddb6SLionel Sambuc{ 6514684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 6524684ddb6SLionel Sambuc try 6534684ddb6SLionel Sambuc { 6544684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 6554684ddb6SLionel Sambuc sentry __s(*this); 6564684ddb6SLionel Sambuc if (__s) 6574684ddb6SLionel Sambuc { 6584684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 6594684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 6604684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 6614684ddb6SLionel Sambuc long __temp; 6624684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); 6634684ddb6SLionel Sambuc if (__temp < numeric_limits<short>::min()) 6644684ddb6SLionel Sambuc { 6654684ddb6SLionel Sambuc __err |= ios_base::failbit; 6664684ddb6SLionel Sambuc __n = numeric_limits<short>::min(); 6674684ddb6SLionel Sambuc } 6684684ddb6SLionel Sambuc else if (__temp > numeric_limits<short>::max()) 6694684ddb6SLionel Sambuc { 6704684ddb6SLionel Sambuc __err |= ios_base::failbit; 6714684ddb6SLionel Sambuc __n = numeric_limits<short>::max(); 6724684ddb6SLionel Sambuc } 6734684ddb6SLionel Sambuc else 6744684ddb6SLionel Sambuc __n = static_cast<short>(__temp); 6754684ddb6SLionel Sambuc this->setstate(__err); 6764684ddb6SLionel Sambuc } 6774684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 6784684ddb6SLionel Sambuc } 6794684ddb6SLionel Sambuc catch (...) 6804684ddb6SLionel Sambuc { 6814684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 6824684ddb6SLionel Sambuc } 6834684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 6844684ddb6SLionel Sambuc return *this; 6854684ddb6SLionel Sambuc} 6864684ddb6SLionel Sambuc 6874684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 6884684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 6894684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(int& __n) 6904684ddb6SLionel Sambuc{ 6914684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 6924684ddb6SLionel Sambuc try 6934684ddb6SLionel Sambuc { 6944684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 6954684ddb6SLionel Sambuc sentry __s(*this); 6964684ddb6SLionel Sambuc if (__s) 6974684ddb6SLionel Sambuc { 6984684ddb6SLionel Sambuc typedef istreambuf_iterator<char_type, traits_type> _Ip; 6994684ddb6SLionel Sambuc typedef num_get<char_type, _Ip> _Fp; 7004684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 7014684ddb6SLionel Sambuc long __temp; 7024684ddb6SLionel Sambuc use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); 7034684ddb6SLionel Sambuc if (__temp < numeric_limits<int>::min()) 7044684ddb6SLionel Sambuc { 7054684ddb6SLionel Sambuc __err |= ios_base::failbit; 7064684ddb6SLionel Sambuc __n = numeric_limits<int>::min(); 7074684ddb6SLionel Sambuc } 7084684ddb6SLionel Sambuc else if (__temp > numeric_limits<int>::max()) 7094684ddb6SLionel Sambuc { 7104684ddb6SLionel Sambuc __err |= ios_base::failbit; 7114684ddb6SLionel Sambuc __n = numeric_limits<int>::max(); 7124684ddb6SLionel Sambuc } 7134684ddb6SLionel Sambuc else 7144684ddb6SLionel Sambuc __n = static_cast<int>(__temp); 7154684ddb6SLionel Sambuc this->setstate(__err); 7164684ddb6SLionel Sambuc } 7174684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 7184684ddb6SLionel Sambuc } 7194684ddb6SLionel Sambuc catch (...) 7204684ddb6SLionel Sambuc { 7214684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 7224684ddb6SLionel Sambuc } 7234684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 7244684ddb6SLionel Sambuc return *this; 7254684ddb6SLionel Sambuc} 7264684ddb6SLionel Sambuc 7274684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 7284684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7294684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 7304684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&)) 7314684ddb6SLionel Sambuc{ 7324684ddb6SLionel Sambuc return __pf(*this); 7334684ddb6SLionel Sambuc} 7344684ddb6SLionel Sambuc 7354684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 7364684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7374684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 7384684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(basic_ios<char_type, traits_type>& 7394684ddb6SLionel Sambuc (*__pf)(basic_ios<char_type, traits_type>&)) 7404684ddb6SLionel Sambuc{ 7414684ddb6SLionel Sambuc __pf(*this); 7424684ddb6SLionel Sambuc return *this; 7434684ddb6SLionel Sambuc} 7444684ddb6SLionel Sambuc 7454684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 7464684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7474684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 7484684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&)) 7494684ddb6SLionel Sambuc{ 7504684ddb6SLionel Sambuc __pf(*this); 7514684ddb6SLionel Sambuc return *this; 7524684ddb6SLionel Sambuc} 7534684ddb6SLionel Sambuc 7544684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 7554684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 7564684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s) 7574684ddb6SLionel Sambuc{ 7584684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 7594684ddb6SLionel Sambuc try 7604684ddb6SLionel Sambuc { 7614684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 7624684ddb6SLionel Sambuc typename basic_istream<_CharT, _Traits>::sentry __sen(__is); 7634684ddb6SLionel Sambuc if (__sen) 7644684ddb6SLionel Sambuc { 7654684ddb6SLionel Sambuc streamsize __n = __is.width(); 7664684ddb6SLionel Sambuc if (__n <= 0) 7674684ddb6SLionel Sambuc __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1; 7684684ddb6SLionel Sambuc streamsize __c = 0; 7694684ddb6SLionel Sambuc const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); 7704684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 7714684ddb6SLionel Sambuc while (__c < __n-1) 7724684ddb6SLionel Sambuc { 7734684ddb6SLionel Sambuc typename _Traits::int_type __i = __is.rdbuf()->sgetc(); 7744684ddb6SLionel Sambuc if (_Traits::eq_int_type(__i, _Traits::eof())) 7754684ddb6SLionel Sambuc { 7764684ddb6SLionel Sambuc __err |= ios_base::eofbit; 7774684ddb6SLionel Sambuc break; 7784684ddb6SLionel Sambuc } 7794684ddb6SLionel Sambuc _CharT __ch = _Traits::to_char_type(__i); 7804684ddb6SLionel Sambuc if (__ct.is(__ct.space, __ch)) 7814684ddb6SLionel Sambuc break; 7824684ddb6SLionel Sambuc *__s++ = __ch; 7834684ddb6SLionel Sambuc ++__c; 7844684ddb6SLionel Sambuc __is.rdbuf()->sbumpc(); 7854684ddb6SLionel Sambuc } 7864684ddb6SLionel Sambuc *__s = _CharT(); 7874684ddb6SLionel Sambuc __is.width(0); 7884684ddb6SLionel Sambuc if (__c == 0) 7894684ddb6SLionel Sambuc __err |= ios_base::failbit; 7904684ddb6SLionel Sambuc __is.setstate(__err); 7914684ddb6SLionel Sambuc } 7924684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 7934684ddb6SLionel Sambuc } 7944684ddb6SLionel Sambuc catch (...) 7954684ddb6SLionel Sambuc { 7964684ddb6SLionel Sambuc __is.__set_badbit_and_consider_rethrow(); 7974684ddb6SLionel Sambuc } 7984684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 7994684ddb6SLionel Sambuc return __is; 8004684ddb6SLionel Sambuc} 8014684ddb6SLionel Sambuc 8024684ddb6SLionel Sambuctemplate<class _Traits> 8034684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8044684ddb6SLionel Sambucbasic_istream<char, _Traits>& 8054684ddb6SLionel Sambucoperator>>(basic_istream<char, _Traits>& __is, unsigned char* __s) 8064684ddb6SLionel Sambuc{ 8074684ddb6SLionel Sambuc return __is >> (char*)__s; 8084684ddb6SLionel Sambuc} 8094684ddb6SLionel Sambuc 8104684ddb6SLionel Sambuctemplate<class _Traits> 8114684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8124684ddb6SLionel Sambucbasic_istream<char, _Traits>& 8134684ddb6SLionel Sambucoperator>>(basic_istream<char, _Traits>& __is, signed char* __s) 8144684ddb6SLionel Sambuc{ 8154684ddb6SLionel Sambuc return __is >> (char*)__s; 8164684ddb6SLionel Sambuc} 8174684ddb6SLionel Sambuc 8184684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 8194684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 8204684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) 8214684ddb6SLionel Sambuc{ 8224684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 8234684ddb6SLionel Sambuc try 8244684ddb6SLionel Sambuc { 8254684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 8264684ddb6SLionel Sambuc typename basic_istream<_CharT, _Traits>::sentry __sen(__is); 8274684ddb6SLionel Sambuc if (__sen) 8284684ddb6SLionel Sambuc { 8294684ddb6SLionel Sambuc typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); 8304684ddb6SLionel Sambuc if (_Traits::eq_int_type(__i, _Traits::eof())) 8314684ddb6SLionel Sambuc __is.setstate(ios_base::eofbit | ios_base::failbit); 8324684ddb6SLionel Sambuc else 8334684ddb6SLionel Sambuc __c = _Traits::to_char_type(__i); 8344684ddb6SLionel Sambuc } 8354684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 8364684ddb6SLionel Sambuc } 8374684ddb6SLionel Sambuc catch (...) 8384684ddb6SLionel Sambuc { 8394684ddb6SLionel Sambuc __is.__set_badbit_and_consider_rethrow(); 8404684ddb6SLionel Sambuc } 8414684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 8424684ddb6SLionel Sambuc return __is; 8434684ddb6SLionel Sambuc} 8444684ddb6SLionel Sambuc 8454684ddb6SLionel Sambuctemplate<class _Traits> 8464684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8474684ddb6SLionel Sambucbasic_istream<char, _Traits>& 8484684ddb6SLionel Sambucoperator>>(basic_istream<char, _Traits>& __is, unsigned char& __c) 8494684ddb6SLionel Sambuc{ 8504684ddb6SLionel Sambuc return __is >> (char&)__c; 8514684ddb6SLionel Sambuc} 8524684ddb6SLionel Sambuc 8534684ddb6SLionel Sambuctemplate<class _Traits> 8544684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8554684ddb6SLionel Sambucbasic_istream<char, _Traits>& 8564684ddb6SLionel Sambucoperator>>(basic_istream<char, _Traits>& __is, signed char& __c) 8574684ddb6SLionel Sambuc{ 8584684ddb6SLionel Sambuc return __is >> (char&)__c; 8594684ddb6SLionel Sambuc} 8604684ddb6SLionel Sambuc 8614684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 8624684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 8634684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb) 8644684ddb6SLionel Sambuc{ 8654684ddb6SLionel Sambuc __gc_ = 0; 8664684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 8674684ddb6SLionel Sambuc try 8684684ddb6SLionel Sambuc { 8694684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 8704684ddb6SLionel Sambuc sentry __s(*this, true); 8714684ddb6SLionel Sambuc if (__s) 8724684ddb6SLionel Sambuc { 8734684ddb6SLionel Sambuc if (__sb) 8744684ddb6SLionel Sambuc { 8754684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 8764684ddb6SLionel Sambuc try 8774684ddb6SLionel Sambuc { 8784684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 8794684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 8804684ddb6SLionel Sambuc while (true) 8814684ddb6SLionel Sambuc { 8824684ddb6SLionel Sambuc typename traits_type::int_type __i = this->rdbuf()->sgetc(); 8834684ddb6SLionel Sambuc if (traits_type::eq_int_type(__i, _Traits::eof())) 8844684ddb6SLionel Sambuc { 8854684ddb6SLionel Sambuc __err |= ios_base::eofbit; 8864684ddb6SLionel Sambuc break; 8874684ddb6SLionel Sambuc } 8884684ddb6SLionel Sambuc if (traits_type::eq_int_type( 8894684ddb6SLionel Sambuc __sb->sputc(traits_type::to_char_type(__i)), 8904684ddb6SLionel Sambuc traits_type::eof())) 8914684ddb6SLionel Sambuc break; 8924684ddb6SLionel Sambuc ++__gc_; 8934684ddb6SLionel Sambuc this->rdbuf()->sbumpc(); 8944684ddb6SLionel Sambuc } 8954684ddb6SLionel Sambuc if (__gc_ == 0) 8964684ddb6SLionel Sambuc __err |= ios_base::failbit; 8974684ddb6SLionel Sambuc this->setstate(__err); 8984684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 8994684ddb6SLionel Sambuc } 9004684ddb6SLionel Sambuc catch (...) 9014684ddb6SLionel Sambuc { 9024684ddb6SLionel Sambuc if (__gc_ == 0) 9034684ddb6SLionel Sambuc this->__set_failbit_and_consider_rethrow(); 9044684ddb6SLionel Sambuc } 9054684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 9064684ddb6SLionel Sambuc } 9074684ddb6SLionel Sambuc else 9084684ddb6SLionel Sambuc this->setstate(ios_base::failbit); 9094684ddb6SLionel Sambuc } 9104684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 9114684ddb6SLionel Sambuc } 9124684ddb6SLionel Sambuc catch (...) 9134684ddb6SLionel Sambuc { 9144684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 9154684ddb6SLionel Sambuc } 9164684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 9174684ddb6SLionel Sambuc return *this; 9184684ddb6SLionel Sambuc} 9194684ddb6SLionel Sambuc 9204684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 9214684ddb6SLionel Sambuctypename basic_istream<_CharT, _Traits>::int_type 9224684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::get() 9234684ddb6SLionel Sambuc{ 9244684ddb6SLionel Sambuc __gc_ = 0; 9254684ddb6SLionel Sambuc int_type __r = traits_type::eof(); 9264684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 9274684ddb6SLionel Sambuc try 9284684ddb6SLionel Sambuc { 9294684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 9304684ddb6SLionel Sambuc sentry __s(*this, true); 9314684ddb6SLionel Sambuc if (__s) 9324684ddb6SLionel Sambuc { 9334684ddb6SLionel Sambuc __r = this->rdbuf()->sbumpc(); 9344684ddb6SLionel Sambuc if (traits_type::eq_int_type(__r, traits_type::eof())) 9354684ddb6SLionel Sambuc this->setstate(ios_base::failbit | ios_base::eofbit); 9364684ddb6SLionel Sambuc else 9374684ddb6SLionel Sambuc __gc_ = 1; 9384684ddb6SLionel Sambuc } 9394684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 9404684ddb6SLionel Sambuc } 9414684ddb6SLionel Sambuc catch (...) 9424684ddb6SLionel Sambuc { 9434684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 9444684ddb6SLionel Sambuc } 9454684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 9464684ddb6SLionel Sambuc return __r; 9474684ddb6SLionel Sambuc} 9484684ddb6SLionel Sambuc 9494684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 9504684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9514684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 9524684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::get(char_type& __c) 9534684ddb6SLionel Sambuc{ 9544684ddb6SLionel Sambuc int_type __ch = get(); 9554684ddb6SLionel Sambuc if (__ch != traits_type::eof()) 9564684ddb6SLionel Sambuc __c = traits_type::to_char_type(__ch); 9574684ddb6SLionel Sambuc return *this; 9584684ddb6SLionel Sambuc} 9594684ddb6SLionel Sambuc 9604684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 9614684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 9624684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm) 9634684ddb6SLionel Sambuc{ 9644684ddb6SLionel Sambuc __gc_ = 0; 9654684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 9664684ddb6SLionel Sambuc try 9674684ddb6SLionel Sambuc { 9684684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 9694684ddb6SLionel Sambuc sentry __sen(*this, true); 9704684ddb6SLionel Sambuc if (__sen) 9714684ddb6SLionel Sambuc { 9724684ddb6SLionel Sambuc if (__n > 0) 9734684ddb6SLionel Sambuc { 9744684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 9754684ddb6SLionel Sambuc while (__gc_ < __n-1) 9764684ddb6SLionel Sambuc { 9774684ddb6SLionel Sambuc int_type __i = this->rdbuf()->sgetc(); 9784684ddb6SLionel Sambuc if (traits_type::eq_int_type(__i, traits_type::eof())) 9794684ddb6SLionel Sambuc { 9804684ddb6SLionel Sambuc __err |= ios_base::eofbit; 9814684ddb6SLionel Sambuc break; 9824684ddb6SLionel Sambuc } 9834684ddb6SLionel Sambuc char_type __ch = traits_type::to_char_type(__i); 9844684ddb6SLionel Sambuc if (traits_type::eq(__ch, __dlm)) 9854684ddb6SLionel Sambuc break; 9864684ddb6SLionel Sambuc *__s++ = __ch; 9874684ddb6SLionel Sambuc ++__gc_; 9884684ddb6SLionel Sambuc this->rdbuf()->sbumpc(); 9894684ddb6SLionel Sambuc } 9904684ddb6SLionel Sambuc *__s = char_type(); 9914684ddb6SLionel Sambuc if (__gc_ == 0) 9924684ddb6SLionel Sambuc __err |= ios_base::failbit; 9934684ddb6SLionel Sambuc this->setstate(__err); 9944684ddb6SLionel Sambuc } 9954684ddb6SLionel Sambuc else 9964684ddb6SLionel Sambuc this->setstate(ios_base::failbit); 9974684ddb6SLionel Sambuc } 9984684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 9994684ddb6SLionel Sambuc } 10004684ddb6SLionel Sambuc catch (...) 10014684ddb6SLionel Sambuc { 10024684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 10034684ddb6SLionel Sambuc } 10044684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 10054684ddb6SLionel Sambuc return *this; 10064684ddb6SLionel Sambuc} 10074684ddb6SLionel Sambuc 10084684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 10094684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10104684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 10114684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n) 10124684ddb6SLionel Sambuc{ 10134684ddb6SLionel Sambuc return get(__s, __n, this->widen('\n')); 10144684ddb6SLionel Sambuc} 10154684ddb6SLionel Sambuc 10164684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 10174684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 10184684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb, 10194684ddb6SLionel Sambuc char_type __dlm) 10204684ddb6SLionel Sambuc{ 10214684ddb6SLionel Sambuc __gc_ = 0; 10224684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 10234684ddb6SLionel Sambuc try 10244684ddb6SLionel Sambuc { 10254684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 10264684ddb6SLionel Sambuc sentry __sen(*this, true); 10274684ddb6SLionel Sambuc if (__sen) 10284684ddb6SLionel Sambuc { 10294684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 10304684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 10314684ddb6SLionel Sambuc try 10324684ddb6SLionel Sambuc { 10334684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 10344684ddb6SLionel Sambuc while (true) 10354684ddb6SLionel Sambuc { 10364684ddb6SLionel Sambuc typename traits_type::int_type __i = this->rdbuf()->sgetc(); 10374684ddb6SLionel Sambuc if (traits_type::eq_int_type(__i, traits_type::eof())) 10384684ddb6SLionel Sambuc { 10394684ddb6SLionel Sambuc __err |= ios_base::eofbit; 10404684ddb6SLionel Sambuc break; 10414684ddb6SLionel Sambuc } 10424684ddb6SLionel Sambuc char_type __ch = traits_type::to_char_type(__i); 10434684ddb6SLionel Sambuc if (traits_type::eq(__ch, __dlm)) 10444684ddb6SLionel Sambuc break; 10454684ddb6SLionel Sambuc if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof())) 10464684ddb6SLionel Sambuc break; 10474684ddb6SLionel Sambuc ++__gc_; 10484684ddb6SLionel Sambuc this->rdbuf()->sbumpc(); 10494684ddb6SLionel Sambuc } 10504684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 10514684ddb6SLionel Sambuc } 10524684ddb6SLionel Sambuc catch (...) 10534684ddb6SLionel Sambuc { 10544684ddb6SLionel Sambuc } 10554684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 10564684ddb6SLionel Sambuc if (__gc_ == 0) 10574684ddb6SLionel Sambuc __err |= ios_base::failbit; 10584684ddb6SLionel Sambuc this->setstate(__err); 10594684ddb6SLionel Sambuc } 10604684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 10614684ddb6SLionel Sambuc } 10624684ddb6SLionel Sambuc catch (...) 10634684ddb6SLionel Sambuc { 10644684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 10654684ddb6SLionel Sambuc } 10664684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 10674684ddb6SLionel Sambuc return *this; 10684684ddb6SLionel Sambuc} 10694684ddb6SLionel Sambuc 10704684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 10714684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10724684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 10734684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb) 10744684ddb6SLionel Sambuc{ 10754684ddb6SLionel Sambuc return get(__sb, this->widen('\n')); 10764684ddb6SLionel Sambuc} 10774684ddb6SLionel Sambuc 10784684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 10794684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 10804684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm) 10814684ddb6SLionel Sambuc{ 10824684ddb6SLionel Sambuc __gc_ = 0; 10834684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 10844684ddb6SLionel Sambuc try 10854684ddb6SLionel Sambuc { 10864684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 10874684ddb6SLionel Sambuc sentry __sen(*this, true); 10884684ddb6SLionel Sambuc if (__sen) 10894684ddb6SLionel Sambuc { 10904684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 10914684ddb6SLionel Sambuc while (true) 10924684ddb6SLionel Sambuc { 10934684ddb6SLionel Sambuc typename traits_type::int_type __i = this->rdbuf()->sgetc(); 10944684ddb6SLionel Sambuc if (traits_type::eq_int_type(__i, traits_type::eof())) 10954684ddb6SLionel Sambuc { 10964684ddb6SLionel Sambuc __err |= ios_base::eofbit; 10974684ddb6SLionel Sambuc break; 10984684ddb6SLionel Sambuc } 10994684ddb6SLionel Sambuc char_type __ch = traits_type::to_char_type(__i); 11004684ddb6SLionel Sambuc if (traits_type::eq(__ch, __dlm)) 11014684ddb6SLionel Sambuc { 11024684ddb6SLionel Sambuc this->rdbuf()->sbumpc(); 11034684ddb6SLionel Sambuc ++__gc_; 11044684ddb6SLionel Sambuc break; 11054684ddb6SLionel Sambuc } 11064684ddb6SLionel Sambuc if (__gc_ >= __n-1) 11074684ddb6SLionel Sambuc { 11084684ddb6SLionel Sambuc __err |= ios_base::failbit; 11094684ddb6SLionel Sambuc break; 11104684ddb6SLionel Sambuc } 11114684ddb6SLionel Sambuc *__s++ = __ch; 11124684ddb6SLionel Sambuc this->rdbuf()->sbumpc(); 11134684ddb6SLionel Sambuc ++__gc_; 11144684ddb6SLionel Sambuc } 11154684ddb6SLionel Sambuc if (__n > 0) 11164684ddb6SLionel Sambuc *__s = char_type(); 11174684ddb6SLionel Sambuc if (__gc_ == 0) 11184684ddb6SLionel Sambuc __err |= ios_base::failbit; 11194684ddb6SLionel Sambuc this->setstate(__err); 11204684ddb6SLionel Sambuc } 11214684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 11224684ddb6SLionel Sambuc } 11234684ddb6SLionel Sambuc catch (...) 11244684ddb6SLionel Sambuc { 11254684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 11264684ddb6SLionel Sambuc } 11274684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 11284684ddb6SLionel Sambuc return *this; 11294684ddb6SLionel Sambuc} 11304684ddb6SLionel Sambuc 11314684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 11324684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 11334684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 11344684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n) 11354684ddb6SLionel Sambuc{ 11364684ddb6SLionel Sambuc return getline(__s, __n, this->widen('\n')); 11374684ddb6SLionel Sambuc} 11384684ddb6SLionel Sambuc 11394684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 11404684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 11414684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm) 11424684ddb6SLionel Sambuc{ 11434684ddb6SLionel Sambuc __gc_ = 0; 11444684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 11454684ddb6SLionel Sambuc try 11464684ddb6SLionel Sambuc { 11474684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 11484684ddb6SLionel Sambuc sentry __sen(*this, true); 11494684ddb6SLionel Sambuc if (__sen) 11504684ddb6SLionel Sambuc { 11514684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 11524684ddb6SLionel Sambuc if (__n == numeric_limits<streamsize>::max()) 11534684ddb6SLionel Sambuc { 11544684ddb6SLionel Sambuc while (true) 11554684ddb6SLionel Sambuc { 11564684ddb6SLionel Sambuc typename traits_type::int_type __i = this->rdbuf()->sbumpc(); 11574684ddb6SLionel Sambuc if (traits_type::eq_int_type(__i, traits_type::eof())) 11584684ddb6SLionel Sambuc { 11594684ddb6SLionel Sambuc __err |= ios_base::eofbit; 11604684ddb6SLionel Sambuc break; 11614684ddb6SLionel Sambuc } 11624684ddb6SLionel Sambuc ++__gc_; 11634684ddb6SLionel Sambuc if (traits_type::eq_int_type(__i, __dlm)) 11644684ddb6SLionel Sambuc break; 11654684ddb6SLionel Sambuc } 11664684ddb6SLionel Sambuc } 11674684ddb6SLionel Sambuc else 11684684ddb6SLionel Sambuc { 11694684ddb6SLionel Sambuc while (__gc_ < __n) 11704684ddb6SLionel Sambuc { 11714684ddb6SLionel Sambuc typename traits_type::int_type __i = this->rdbuf()->sbumpc(); 11724684ddb6SLionel Sambuc if (traits_type::eq_int_type(__i, traits_type::eof())) 11734684ddb6SLionel Sambuc { 11744684ddb6SLionel Sambuc __err |= ios_base::eofbit; 11754684ddb6SLionel Sambuc break; 11764684ddb6SLionel Sambuc } 11774684ddb6SLionel Sambuc ++__gc_; 11784684ddb6SLionel Sambuc if (traits_type::eq_int_type(__i, __dlm)) 11794684ddb6SLionel Sambuc break; 11804684ddb6SLionel Sambuc } 11814684ddb6SLionel Sambuc } 11824684ddb6SLionel Sambuc this->setstate(__err); 11834684ddb6SLionel Sambuc } 11844684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 11854684ddb6SLionel Sambuc } 11864684ddb6SLionel Sambuc catch (...) 11874684ddb6SLionel Sambuc { 11884684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 11894684ddb6SLionel Sambuc } 11904684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 11914684ddb6SLionel Sambuc return *this; 11924684ddb6SLionel Sambuc} 11934684ddb6SLionel Sambuc 11944684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 11954684ddb6SLionel Sambuctypename basic_istream<_CharT, _Traits>::int_type 11964684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::peek() 11974684ddb6SLionel Sambuc{ 11984684ddb6SLionel Sambuc __gc_ = 0; 11994684ddb6SLionel Sambuc int_type __r = traits_type::eof(); 12004684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 12014684ddb6SLionel Sambuc try 12024684ddb6SLionel Sambuc { 12034684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 12044684ddb6SLionel Sambuc sentry __sen(*this, true); 12054684ddb6SLionel Sambuc if (__sen) 12064684ddb6SLionel Sambuc { 12074684ddb6SLionel Sambuc __r = this->rdbuf()->sgetc(); 12084684ddb6SLionel Sambuc if (traits_type::eq_int_type(__r, traits_type::eof())) 12094684ddb6SLionel Sambuc this->setstate(ios_base::eofbit); 12104684ddb6SLionel Sambuc } 12114684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 12124684ddb6SLionel Sambuc } 12134684ddb6SLionel Sambuc catch (...) 12144684ddb6SLionel Sambuc { 12154684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 12164684ddb6SLionel Sambuc } 12174684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 12184684ddb6SLionel Sambuc return __r; 12194684ddb6SLionel Sambuc} 12204684ddb6SLionel Sambuc 12214684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 12224684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 12234684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n) 12244684ddb6SLionel Sambuc{ 12254684ddb6SLionel Sambuc __gc_ = 0; 12264684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 12274684ddb6SLionel Sambuc try 12284684ddb6SLionel Sambuc { 12294684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 12304684ddb6SLionel Sambuc sentry __sen(*this, true); 12314684ddb6SLionel Sambuc if (__sen) 12324684ddb6SLionel Sambuc { 12334684ddb6SLionel Sambuc __gc_ = this->rdbuf()->sgetn(__s, __n); 12344684ddb6SLionel Sambuc if (__gc_ != __n) 12354684ddb6SLionel Sambuc this->setstate(ios_base::failbit | ios_base::eofbit); 12364684ddb6SLionel Sambuc } 12374684ddb6SLionel Sambuc else 12384684ddb6SLionel Sambuc this->setstate(ios_base::failbit); 12394684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 12404684ddb6SLionel Sambuc } 12414684ddb6SLionel Sambuc catch (...) 12424684ddb6SLionel Sambuc { 12434684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 12444684ddb6SLionel Sambuc } 12454684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 12464684ddb6SLionel Sambuc return *this; 12474684ddb6SLionel Sambuc} 12484684ddb6SLionel Sambuc 12494684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 12504684ddb6SLionel Sambucstreamsize 12514684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n) 12524684ddb6SLionel Sambuc{ 12534684ddb6SLionel Sambuc __gc_ = 0; 12544684ddb6SLionel Sambuc streamsize __c = this->rdbuf()->in_avail(); 12554684ddb6SLionel Sambuc switch (__c) 12564684ddb6SLionel Sambuc { 12574684ddb6SLionel Sambuc case -1: 12584684ddb6SLionel Sambuc this->setstate(ios_base::eofbit); 12594684ddb6SLionel Sambuc break; 12604684ddb6SLionel Sambuc case 0: 12614684ddb6SLionel Sambuc break; 12624684ddb6SLionel Sambuc default: 12634684ddb6SLionel Sambuc read(__s, _VSTD::min(__c, __n)); 12644684ddb6SLionel Sambuc break; 12654684ddb6SLionel Sambuc } 12664684ddb6SLionel Sambuc return __gc_; 12674684ddb6SLionel Sambuc} 12684684ddb6SLionel Sambuc 12694684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 12704684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 12714684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::putback(char_type __c) 12724684ddb6SLionel Sambuc{ 12734684ddb6SLionel Sambuc __gc_ = 0; 12744684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 12754684ddb6SLionel Sambuc try 12764684ddb6SLionel Sambuc { 12774684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 12784684ddb6SLionel Sambuc this->clear(this->rdstate() & ~ios_base::eofbit); 12794684ddb6SLionel Sambuc sentry __sen(*this, true); 12804684ddb6SLionel Sambuc if (__sen) 12814684ddb6SLionel Sambuc { 12824684ddb6SLionel Sambuc if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof()) 12834684ddb6SLionel Sambuc this->setstate(ios_base::badbit); 12844684ddb6SLionel Sambuc } 12854684ddb6SLionel Sambuc else 12864684ddb6SLionel Sambuc this->setstate(ios_base::failbit); 12874684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 12884684ddb6SLionel Sambuc } 12894684ddb6SLionel Sambuc catch (...) 12904684ddb6SLionel Sambuc { 12914684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 12924684ddb6SLionel Sambuc } 12934684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 12944684ddb6SLionel Sambuc return *this; 12954684ddb6SLionel Sambuc} 12964684ddb6SLionel Sambuc 12974684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 12984684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 12994684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::unget() 13004684ddb6SLionel Sambuc{ 13014684ddb6SLionel Sambuc __gc_ = 0; 13024684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 13034684ddb6SLionel Sambuc try 13044684ddb6SLionel Sambuc { 13054684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 13064684ddb6SLionel Sambuc this->clear(this->rdstate() & ~ios_base::eofbit); 13074684ddb6SLionel Sambuc sentry __sen(*this, true); 13084684ddb6SLionel Sambuc if (__sen) 13094684ddb6SLionel Sambuc { 13104684ddb6SLionel Sambuc if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof()) 13114684ddb6SLionel Sambuc this->setstate(ios_base::badbit); 13124684ddb6SLionel Sambuc } 13134684ddb6SLionel Sambuc else 13144684ddb6SLionel Sambuc this->setstate(ios_base::failbit); 13154684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 13164684ddb6SLionel Sambuc } 13174684ddb6SLionel Sambuc catch (...) 13184684ddb6SLionel Sambuc { 13194684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 13204684ddb6SLionel Sambuc } 13214684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 13224684ddb6SLionel Sambuc return *this; 13234684ddb6SLionel Sambuc} 13244684ddb6SLionel Sambuc 13254684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 13264684ddb6SLionel Sambucint 13274684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::sync() 13284684ddb6SLionel Sambuc{ 13294684ddb6SLionel Sambuc int __r = 0; 13304684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 13314684ddb6SLionel Sambuc try 13324684ddb6SLionel Sambuc { 13334684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 13344684ddb6SLionel Sambuc sentry __sen(*this, true); 13354684ddb6SLionel Sambuc if (__sen) 13364684ddb6SLionel Sambuc { 13374684ddb6SLionel Sambuc if (this->rdbuf() == 0) 13384684ddb6SLionel Sambuc return -1; 13394684ddb6SLionel Sambuc if (this->rdbuf()->pubsync() == -1) 13404684ddb6SLionel Sambuc { 13414684ddb6SLionel Sambuc this->setstate(ios_base::badbit); 13424684ddb6SLionel Sambuc return -1; 13434684ddb6SLionel Sambuc } 13444684ddb6SLionel Sambuc } 13454684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 13464684ddb6SLionel Sambuc } 13474684ddb6SLionel Sambuc catch (...) 13484684ddb6SLionel Sambuc { 13494684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 13504684ddb6SLionel Sambuc } 13514684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 13524684ddb6SLionel Sambuc return __r; 13534684ddb6SLionel Sambuc} 13544684ddb6SLionel Sambuc 13554684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 13564684ddb6SLionel Sambuctypename basic_istream<_CharT, _Traits>::pos_type 13574684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::tellg() 13584684ddb6SLionel Sambuc{ 13594684ddb6SLionel Sambuc pos_type __r(-1); 13604684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 13614684ddb6SLionel Sambuc try 13624684ddb6SLionel Sambuc { 13634684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 13644684ddb6SLionel Sambuc sentry __sen(*this, true); 13654684ddb6SLionel Sambuc if (__sen) 13664684ddb6SLionel Sambuc __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); 13674684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 13684684ddb6SLionel Sambuc } 13694684ddb6SLionel Sambuc catch (...) 13704684ddb6SLionel Sambuc { 13714684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 13724684ddb6SLionel Sambuc } 13734684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 13744684ddb6SLionel Sambuc return __r; 13754684ddb6SLionel Sambuc} 13764684ddb6SLionel Sambuc 13774684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 13784684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 13794684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::seekg(pos_type __pos) 13804684ddb6SLionel Sambuc{ 13814684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 13824684ddb6SLionel Sambuc try 13834684ddb6SLionel Sambuc { 13844684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 13854684ddb6SLionel Sambuc this->clear(this->rdstate() & ~ios_base::eofbit); 13864684ddb6SLionel Sambuc sentry __sen(*this, true); 13874684ddb6SLionel Sambuc if (__sen) 13884684ddb6SLionel Sambuc { 13894684ddb6SLionel Sambuc if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) 13904684ddb6SLionel Sambuc this->setstate(ios_base::failbit); 13914684ddb6SLionel Sambuc } 13924684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 13934684ddb6SLionel Sambuc } 13944684ddb6SLionel Sambuc catch (...) 13954684ddb6SLionel Sambuc { 13964684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 13974684ddb6SLionel Sambuc } 13984684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 13994684ddb6SLionel Sambuc return *this; 14004684ddb6SLionel Sambuc} 14014684ddb6SLionel Sambuc 14024684ddb6SLionel Sambuctemplate<class _CharT, class _Traits> 14034684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 14044684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) 14054684ddb6SLionel Sambuc{ 14064684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 14074684ddb6SLionel Sambuc try 14084684ddb6SLionel Sambuc { 14094684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 14104684ddb6SLionel Sambuc sentry __sen(*this, true); 14114684ddb6SLionel Sambuc if (__sen) 14124684ddb6SLionel Sambuc { 14134684ddb6SLionel Sambuc if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) 14144684ddb6SLionel Sambuc this->setstate(ios_base::failbit); 14154684ddb6SLionel Sambuc } 14164684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 14174684ddb6SLionel Sambuc } 14184684ddb6SLionel Sambuc catch (...) 14194684ddb6SLionel Sambuc { 14204684ddb6SLionel Sambuc this->__set_badbit_and_consider_rethrow(); 14214684ddb6SLionel Sambuc } 14224684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 14234684ddb6SLionel Sambuc return *this; 14244684ddb6SLionel Sambuc} 14254684ddb6SLionel Sambuc 14264684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 14274684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 14284684ddb6SLionel Sambucws(basic_istream<_CharT, _Traits>& __is) 14294684ddb6SLionel Sambuc{ 14304684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 14314684ddb6SLionel Sambuc try 14324684ddb6SLionel Sambuc { 14334684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 14344684ddb6SLionel Sambuc typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); 14354684ddb6SLionel Sambuc if (__sen) 14364684ddb6SLionel Sambuc { 14374684ddb6SLionel Sambuc const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); 14384684ddb6SLionel Sambuc while (true) 14394684ddb6SLionel Sambuc { 14404684ddb6SLionel Sambuc typename _Traits::int_type __i = __is.rdbuf()->sgetc(); 14414684ddb6SLionel Sambuc if (_Traits::eq_int_type(__i, _Traits::eof())) 14424684ddb6SLionel Sambuc { 14434684ddb6SLionel Sambuc __is.setstate(ios_base::eofbit); 14444684ddb6SLionel Sambuc break; 14454684ddb6SLionel Sambuc } 14464684ddb6SLionel Sambuc if (!__ct.is(__ct.space, _Traits::to_char_type(__i))) 14474684ddb6SLionel Sambuc break; 14484684ddb6SLionel Sambuc __is.rdbuf()->sbumpc(); 14494684ddb6SLionel Sambuc } 14504684ddb6SLionel Sambuc } 14514684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 14524684ddb6SLionel Sambuc } 14534684ddb6SLionel Sambuc catch (...) 14544684ddb6SLionel Sambuc { 14554684ddb6SLionel Sambuc __is.__set_badbit_and_consider_rethrow(); 14564684ddb6SLionel Sambuc } 14574684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 14584684ddb6SLionel Sambuc return __is; 14594684ddb6SLionel Sambuc} 14604684ddb6SLionel Sambuc 14614684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 14624684ddb6SLionel Sambuc 14634684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Tp> 14644684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 14654684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 14664684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) 14674684ddb6SLionel Sambuc{ 14684684ddb6SLionel Sambuc __is >> __x; 14694684ddb6SLionel Sambuc return __is; 14704684ddb6SLionel Sambuc} 14714684ddb6SLionel Sambuc 14724684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 14734684ddb6SLionel Sambuc 14744684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 14754684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY basic_iostream 14764684ddb6SLionel Sambuc : public basic_istream<_CharT, _Traits>, 14774684ddb6SLionel Sambuc public basic_ostream<_CharT, _Traits> 14784684ddb6SLionel Sambuc{ 14794684ddb6SLionel Sambucpublic: 14804684ddb6SLionel Sambuc // types: 14814684ddb6SLionel Sambuc typedef _CharT char_type; 14824684ddb6SLionel Sambuc typedef _Traits traits_type; 14834684ddb6SLionel Sambuc typedef typename traits_type::int_type int_type; 14844684ddb6SLionel Sambuc typedef typename traits_type::pos_type pos_type; 14854684ddb6SLionel Sambuc typedef typename traits_type::off_type off_type; 14864684ddb6SLionel Sambuc 14874684ddb6SLionel Sambuc // constructor/destructor 14884684ddb6SLionel Sambuc explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb); 14894684ddb6SLionel Sambuc virtual ~basic_iostream(); 14904684ddb6SLionel Sambucprotected: 14914684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 14924684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14934684ddb6SLionel Sambuc basic_iostream(basic_iostream&& __rhs); 14944684ddb6SLionel Sambuc#endif 14954684ddb6SLionel Sambuc 14964684ddb6SLionel Sambuc // assign/swap 14974684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 14984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14994684ddb6SLionel Sambuc basic_iostream& operator=(basic_iostream&& __rhs); 15004684ddb6SLionel Sambuc#endif 15014684ddb6SLionel Sambuc void swap(basic_iostream& __rhs); 15024684ddb6SLionel Sambucpublic: 15034684ddb6SLionel Sambuc}; 15044684ddb6SLionel Sambuc 15054684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 15064684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15074684ddb6SLionel Sambucbasic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf<char_type, traits_type>* __sb) 15084684ddb6SLionel Sambuc : basic_istream<_CharT, _Traits>(__sb) 15094684ddb6SLionel Sambuc{ 15104684ddb6SLionel Sambuc} 15114684ddb6SLionel Sambuc 15124684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 15134684ddb6SLionel Sambuc 15144684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 15154684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15164684ddb6SLionel Sambucbasic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs) 15174684ddb6SLionel Sambuc : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)) 15184684ddb6SLionel Sambuc{ 15194684ddb6SLionel Sambuc} 15204684ddb6SLionel Sambuc 15214684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 15224684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15234684ddb6SLionel Sambucbasic_iostream<_CharT, _Traits>& 15244684ddb6SLionel Sambucbasic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs) 15254684ddb6SLionel Sambuc{ 15264684ddb6SLionel Sambuc swap(__rhs); 15274684ddb6SLionel Sambuc return *this; 15284684ddb6SLionel Sambuc} 15294684ddb6SLionel Sambuc 15304684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 15314684ddb6SLionel Sambuc 15324684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 15334684ddb6SLionel Sambucbasic_iostream<_CharT, _Traits>::~basic_iostream() 15344684ddb6SLionel Sambuc{ 15354684ddb6SLionel Sambuc} 15364684ddb6SLionel Sambuc 15374684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 15384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 15394684ddb6SLionel Sambucvoid 15404684ddb6SLionel Sambucbasic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs) 15414684ddb6SLionel Sambuc{ 15424684ddb6SLionel Sambuc basic_istream<char_type, traits_type>::swap(__rhs); 15434684ddb6SLionel Sambuc} 15444684ddb6SLionel Sambuc 15454684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 15464684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 15474684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, 15484684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str) 15494684ddb6SLionel Sambuc{ 15504684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 15514684ddb6SLionel Sambuc try 15524684ddb6SLionel Sambuc { 15534684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 15544684ddb6SLionel Sambuc typename basic_istream<_CharT, _Traits>::sentry __sen(__is); 15554684ddb6SLionel Sambuc if (__sen) 15564684ddb6SLionel Sambuc { 15574684ddb6SLionel Sambuc __str.clear(); 15584684ddb6SLionel Sambuc streamsize __n = __is.width(); 15594684ddb6SLionel Sambuc if (__n <= 0) 15604684ddb6SLionel Sambuc __n = __str.max_size(); 15614684ddb6SLionel Sambuc if (__n <= 0) 15624684ddb6SLionel Sambuc __n = numeric_limits<streamsize>::max(); 15634684ddb6SLionel Sambuc streamsize __c = 0; 15644684ddb6SLionel Sambuc const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); 15654684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 15664684ddb6SLionel Sambuc while (__c < __n) 15674684ddb6SLionel Sambuc { 15684684ddb6SLionel Sambuc typename _Traits::int_type __i = __is.rdbuf()->sgetc(); 15694684ddb6SLionel Sambuc if (_Traits::eq_int_type(__i, _Traits::eof())) 15704684ddb6SLionel Sambuc { 15714684ddb6SLionel Sambuc __err |= ios_base::eofbit; 15724684ddb6SLionel Sambuc break; 15734684ddb6SLionel Sambuc } 15744684ddb6SLionel Sambuc _CharT __ch = _Traits::to_char_type(__i); 15754684ddb6SLionel Sambuc if (__ct.is(__ct.space, __ch)) 15764684ddb6SLionel Sambuc break; 15774684ddb6SLionel Sambuc __str.push_back(__ch); 15784684ddb6SLionel Sambuc ++__c; 15794684ddb6SLionel Sambuc __is.rdbuf()->sbumpc(); 15804684ddb6SLionel Sambuc } 15814684ddb6SLionel Sambuc __is.width(0); 15824684ddb6SLionel Sambuc if (__c == 0) 15834684ddb6SLionel Sambuc __err |= ios_base::failbit; 15844684ddb6SLionel Sambuc __is.setstate(__err); 15854684ddb6SLionel Sambuc } 15864684ddb6SLionel Sambuc else 15874684ddb6SLionel Sambuc __is.setstate(ios_base::failbit); 15884684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 15894684ddb6SLionel Sambuc } 15904684ddb6SLionel Sambuc catch (...) 15914684ddb6SLionel Sambuc { 15924684ddb6SLionel Sambuc __is.__set_badbit_and_consider_rethrow(); 15934684ddb6SLionel Sambuc } 15944684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 15954684ddb6SLionel Sambuc return __is; 15964684ddb6SLionel Sambuc} 15974684ddb6SLionel Sambuc 15984684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 15994684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 16004684ddb6SLionel Sambucgetline(basic_istream<_CharT, _Traits>& __is, 16014684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) 16024684ddb6SLionel Sambuc{ 16034684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 16044684ddb6SLionel Sambuc try 16054684ddb6SLionel Sambuc { 16064684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 16074684ddb6SLionel Sambuc typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); 16084684ddb6SLionel Sambuc if (__sen) 16094684ddb6SLionel Sambuc { 16104684ddb6SLionel Sambuc __str.clear(); 16114684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 16124684ddb6SLionel Sambuc streamsize __extr = 0; 16134684ddb6SLionel Sambuc while (true) 16144684ddb6SLionel Sambuc { 16154684ddb6SLionel Sambuc typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); 16164684ddb6SLionel Sambuc if (_Traits::eq_int_type(__i, _Traits::eof())) 16174684ddb6SLionel Sambuc { 16184684ddb6SLionel Sambuc __err |= ios_base::eofbit; 16194684ddb6SLionel Sambuc break; 16204684ddb6SLionel Sambuc } 16214684ddb6SLionel Sambuc ++__extr; 16224684ddb6SLionel Sambuc _CharT __ch = _Traits::to_char_type(__i); 16234684ddb6SLionel Sambuc if (_Traits::eq(__ch, __dlm)) 16244684ddb6SLionel Sambuc break; 16254684ddb6SLionel Sambuc __str.push_back(__ch); 16264684ddb6SLionel Sambuc if (__str.size() == __str.max_size()) 16274684ddb6SLionel Sambuc { 16284684ddb6SLionel Sambuc __err |= ios_base::failbit; 16294684ddb6SLionel Sambuc break; 16304684ddb6SLionel Sambuc } 16314684ddb6SLionel Sambuc } 16324684ddb6SLionel Sambuc if (__extr == 0) 16334684ddb6SLionel Sambuc __err |= ios_base::failbit; 16344684ddb6SLionel Sambuc __is.setstate(__err); 16354684ddb6SLionel Sambuc } 16364684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 16374684ddb6SLionel Sambuc } 16384684ddb6SLionel Sambuc catch (...) 16394684ddb6SLionel Sambuc { 16404684ddb6SLionel Sambuc __is.__set_badbit_and_consider_rethrow(); 16414684ddb6SLionel Sambuc } 16424684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 16434684ddb6SLionel Sambuc return __is; 16444684ddb6SLionel Sambuc} 16454684ddb6SLionel Sambuc 16464684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 16474684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16484684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 16494684ddb6SLionel Sambucgetline(basic_istream<_CharT, _Traits>& __is, 16504684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str) 16514684ddb6SLionel Sambuc{ 16524684ddb6SLionel Sambuc return getline(__is, __str, __is.widen('\n')); 16534684ddb6SLionel Sambuc} 16544684ddb6SLionel Sambuc 16554684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 16564684ddb6SLionel Sambuc 16574684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 16584684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16594684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 16604684ddb6SLionel Sambucgetline(basic_istream<_CharT, _Traits>&& __is, 16614684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) 16624684ddb6SLionel Sambuc{ 16634684ddb6SLionel Sambuc return getline(__is, __str, __dlm); 16644684ddb6SLionel Sambuc} 16654684ddb6SLionel Sambuc 16664684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 16674684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 16684684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 16694684ddb6SLionel Sambucgetline(basic_istream<_CharT, _Traits>&& __is, 16704684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str) 16714684ddb6SLionel Sambuc{ 16724684ddb6SLionel Sambuc return getline(__is, __str, __is.widen('\n')); 16734684ddb6SLionel Sambuc} 16744684ddb6SLionel Sambuc 16754684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 16764684ddb6SLionel Sambuc 16774684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, size_t _Size> 16784684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 16794684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) 16804684ddb6SLionel Sambuc{ 16814684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 16824684ddb6SLionel Sambuc try 16834684ddb6SLionel Sambuc { 16844684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 16854684ddb6SLionel Sambuc typename basic_istream<_CharT, _Traits>::sentry __sen(__is); 16864684ddb6SLionel Sambuc if (__sen) 16874684ddb6SLionel Sambuc { 16884684ddb6SLionel Sambuc basic_string<_CharT, _Traits> __str; 16894684ddb6SLionel Sambuc const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); 16904684ddb6SLionel Sambuc streamsize __c = 0; 16914684ddb6SLionel Sambuc ios_base::iostate __err = ios_base::goodbit; 16924684ddb6SLionel Sambuc _CharT __zero = __ct.widen('0'); 16934684ddb6SLionel Sambuc _CharT __one = __ct.widen('1'); 16944684ddb6SLionel Sambuc while (__c < _Size) 16954684ddb6SLionel Sambuc { 16964684ddb6SLionel Sambuc typename _Traits::int_type __i = __is.rdbuf()->sgetc(); 16974684ddb6SLionel Sambuc if (_Traits::eq_int_type(__i, _Traits::eof())) 16984684ddb6SLionel Sambuc { 16994684ddb6SLionel Sambuc __err |= ios_base::eofbit; 17004684ddb6SLionel Sambuc break; 17014684ddb6SLionel Sambuc } 17024684ddb6SLionel Sambuc _CharT __ch = _Traits::to_char_type(__i); 17034684ddb6SLionel Sambuc if (!_Traits::eq(__ch, __zero) && !_Traits::eq(__ch, __one)) 17044684ddb6SLionel Sambuc break; 17054684ddb6SLionel Sambuc __str.push_back(__ch); 17064684ddb6SLionel Sambuc ++__c; 17074684ddb6SLionel Sambuc __is.rdbuf()->sbumpc(); 17084684ddb6SLionel Sambuc } 17094684ddb6SLionel Sambuc __x = bitset<_Size>(__str); 17104684ddb6SLionel Sambuc if (__c == 0) 17114684ddb6SLionel Sambuc __err |= ios_base::failbit; 17124684ddb6SLionel Sambuc __is.setstate(__err); 17134684ddb6SLionel Sambuc } 17144684ddb6SLionel Sambuc else 17154684ddb6SLionel Sambuc __is.setstate(ios_base::failbit); 17164684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 17174684ddb6SLionel Sambuc } 17184684ddb6SLionel Sambuc catch (...) 17194684ddb6SLionel Sambuc { 17204684ddb6SLionel Sambuc __is.__set_badbit_and_consider_rethrow(); 17214684ddb6SLionel Sambuc } 17224684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 17234684ddb6SLionel Sambuc return __is; 17244684ddb6SLionel Sambuc} 17254684ddb6SLionel Sambuc 17264684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<char>) 17274684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<wchar_t>) 17284684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream<char>) 17294684ddb6SLionel Sambuc 17304684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD 17314684ddb6SLionel Sambuc 17324684ddb6SLionel Sambuc#endif // _LIBCPP_ISTREAM 1733