xref: /aosp_15_r20/external/libcxx/include/istream (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===--------------------------- istream ----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_ISTREAM
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_ISTREAM
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    istream synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits = char_traits<charT> >
18*58b9f456SAndroid Build Coastguard Workerclass basic_istream
19*58b9f456SAndroid Build Coastguard Worker    : virtual public basic_ios<charT,traits>
20*58b9f456SAndroid Build Coastguard Worker{
21*58b9f456SAndroid Build Coastguard Workerpublic:
22*58b9f456SAndroid Build Coastguard Worker    // types (inherited from basic_ios (27.5.4)):
23*58b9f456SAndroid Build Coastguard Worker    typedef charT                          char_type;
24*58b9f456SAndroid Build Coastguard Worker    typedef traits                         traits_type;
25*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::int_type int_type;
26*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::pos_type pos_type;
27*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::off_type off_type;
28*58b9f456SAndroid Build Coastguard Worker
29*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.1.1 Constructor/destructor:
30*58b9f456SAndroid Build Coastguard Worker    explicit basic_istream(basic_streambuf<char_type, traits_type>* sb);
31*58b9f456SAndroid Build Coastguard Worker    basic_istream(basic_istream&& rhs);
32*58b9f456SAndroid Build Coastguard Worker    virtual ~basic_istream();
33*58b9f456SAndroid Build Coastguard Worker
34*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.1.2 Assign/swap:
35*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator=(basic_istream&& rhs);
36*58b9f456SAndroid Build Coastguard Worker    void swap(basic_istream& rhs);
37*58b9f456SAndroid Build Coastguard Worker
38*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.1.3 Prefix/suffix:
39*58b9f456SAndroid Build Coastguard Worker    class sentry;
40*58b9f456SAndroid Build Coastguard Worker
41*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.2 Formatted input:
42*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
43*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(basic_ios<char_type, traits_type>&
44*58b9f456SAndroid Build Coastguard Worker                              (*pf)(basic_ios<char_type, traits_type>&));
45*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(ios_base& (*pf)(ios_base&));
46*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(basic_streambuf<char_type, traits_type>* sb);
47*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(bool& n);
48*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(short& n);
49*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(unsigned short& n);
50*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(int& n);
51*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(unsigned int& n);
52*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(long& n);
53*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(unsigned long& n);
54*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(long long& n);
55*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(unsigned long long& n);
56*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(float& f);
57*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(double& f);
58*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(long double& f);
59*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(void*& p);
60*58b9f456SAndroid Build Coastguard Worker
61*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.3 Unformatted input:
62*58b9f456SAndroid Build Coastguard Worker    streamsize gcount() const;
63*58b9f456SAndroid Build Coastguard Worker    int_type get();
64*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(char_type& c);
65*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(char_type* s, streamsize n);
66*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(char_type* s, streamsize n, char_type delim);
67*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(basic_streambuf<char_type,traits_type>& sb);
68*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(basic_streambuf<char_type,traits_type>& sb, char_type delim);
69*58b9f456SAndroid Build Coastguard Worker
70*58b9f456SAndroid Build Coastguard Worker    basic_istream& getline(char_type* s, streamsize n);
71*58b9f456SAndroid Build Coastguard Worker    basic_istream& getline(char_type* s, streamsize n, char_type delim);
72*58b9f456SAndroid Build Coastguard Worker
73*58b9f456SAndroid Build Coastguard Worker    basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof());
74*58b9f456SAndroid Build Coastguard Worker    int_type peek();
75*58b9f456SAndroid Build Coastguard Worker    basic_istream& read (char_type* s, streamsize n);
76*58b9f456SAndroid Build Coastguard Worker    streamsize readsome(char_type* s, streamsize n);
77*58b9f456SAndroid Build Coastguard Worker
78*58b9f456SAndroid Build Coastguard Worker    basic_istream& putback(char_type c);
79*58b9f456SAndroid Build Coastguard Worker    basic_istream& unget();
80*58b9f456SAndroid Build Coastguard Worker    int sync();
81*58b9f456SAndroid Build Coastguard Worker
82*58b9f456SAndroid Build Coastguard Worker    pos_type tellg();
83*58b9f456SAndroid Build Coastguard Worker    basic_istream& seekg(pos_type);
84*58b9f456SAndroid Build Coastguard Worker    basic_istream& seekg(off_type, ios_base::seekdir);
85*58b9f456SAndroid Build Coastguard Workerprotected:
86*58b9f456SAndroid Build Coastguard Worker    basic_istream(const basic_istream& rhs) = delete;
87*58b9f456SAndroid Build Coastguard Worker    basic_istream(basic_istream&& rhs);
88*58b9f456SAndroid Build Coastguard Worker    // 27.7.2.1.2 Assign/swap:
89*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator=(const basic_istream& rhs) = delete;
90*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator=(basic_istream&& rhs);
91*58b9f456SAndroid Build Coastguard Worker    void swap(basic_istream& rhs);
92*58b9f456SAndroid Build Coastguard Worker};
93*58b9f456SAndroid Build Coastguard Worker
94*58b9f456SAndroid Build Coastguard Worker// 27.7.1.2.3 character extraction templates:
95*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits>
96*58b9f456SAndroid Build Coastguard Worker  basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT&);
97*58b9f456SAndroid Build Coastguard Worker
98*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
99*58b9f456SAndroid Build Coastguard Worker  basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char&);
100*58b9f456SAndroid Build Coastguard Worker
101*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
102*58b9f456SAndroid Build Coastguard Worker  basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char&);
103*58b9f456SAndroid Build Coastguard Worker
104*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits>
105*58b9f456SAndroid Build Coastguard Worker  basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT*);
106*58b9f456SAndroid Build Coastguard Worker
107*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
108*58b9f456SAndroid Build Coastguard Worker  basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char*);
109*58b9f456SAndroid Build Coastguard Worker
110*58b9f456SAndroid Build Coastguard Workertemplate<class traits>
111*58b9f456SAndroid Build Coastguard Worker  basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char*);
112*58b9f456SAndroid Build Coastguard Worker
113*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
114*58b9f456SAndroid Build Coastguard Worker  void
115*58b9f456SAndroid Build Coastguard Worker  swap(basic_istream<charT, traits>& x, basic_istream<charT, traits>& y);
116*58b9f456SAndroid Build Coastguard Worker
117*58b9f456SAndroid Build Coastguard Workertypedef basic_istream<char> istream;
118*58b9f456SAndroid Build Coastguard Workertypedef basic_istream<wchar_t> wistream;
119*58b9f456SAndroid Build Coastguard Worker
120*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits = char_traits<charT> >
121*58b9f456SAndroid Build Coastguard Workerclass basic_iostream :
122*58b9f456SAndroid Build Coastguard Worker    public basic_istream<charT,traits>,
123*58b9f456SAndroid Build Coastguard Worker    public basic_ostream<charT,traits>
124*58b9f456SAndroid Build Coastguard Worker{
125*58b9f456SAndroid Build Coastguard Workerpublic:
126*58b9f456SAndroid Build Coastguard Worker    // types:
127*58b9f456SAndroid Build Coastguard Worker    typedef charT                          char_type;
128*58b9f456SAndroid Build Coastguard Worker    typedef traits                         traits_type;
129*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::int_type int_type;
130*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::pos_type pos_type;
131*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::off_type off_type;
132*58b9f456SAndroid Build Coastguard Worker
133*58b9f456SAndroid Build Coastguard Worker    // constructor/destructor
134*58b9f456SAndroid Build Coastguard Worker    explicit basic_iostream(basic_streambuf<char_type, traits_type>* sb);
135*58b9f456SAndroid Build Coastguard Worker    basic_iostream(basic_iostream&& rhs);
136*58b9f456SAndroid Build Coastguard Worker    virtual ~basic_iostream();
137*58b9f456SAndroid Build Coastguard Worker
138*58b9f456SAndroid Build Coastguard Worker    // assign/swap
139*58b9f456SAndroid Build Coastguard Worker    basic_iostream& operator=(basic_iostream&& rhs);
140*58b9f456SAndroid Build Coastguard Worker    void swap(basic_iostream& rhs);
141*58b9f456SAndroid Build Coastguard Worker};
142*58b9f456SAndroid Build Coastguard Worker
143*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
144*58b9f456SAndroid Build Coastguard Worker  void
145*58b9f456SAndroid Build Coastguard Worker  swap(basic_iostream<charT, traits>& x, basic_iostream<charT, traits>& y);
146*58b9f456SAndroid Build Coastguard Worker
147*58b9f456SAndroid Build Coastguard Workertypedef basic_iostream<char> iostream;
148*58b9f456SAndroid Build Coastguard Workertypedef basic_iostream<wchar_t> wiostream;
149*58b9f456SAndroid Build Coastguard Worker
150*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits>
151*58b9f456SAndroid Build Coastguard Worker  basic_istream<charT,traits>&
152*58b9f456SAndroid Build Coastguard Worker  ws(basic_istream<charT,traits>& is);
153*58b9f456SAndroid Build Coastguard Worker
154*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits, class T>
155*58b9f456SAndroid Build Coastguard Worker  basic_istream<charT, traits>&
156*58b9f456SAndroid Build Coastguard Worker  operator>>(basic_istream<charT, traits>&& is, T& x);
157*58b9f456SAndroid Build Coastguard Worker
158*58b9f456SAndroid Build Coastguard Worker}  // std
159*58b9f456SAndroid Build Coastguard Worker
160*58b9f456SAndroid Build Coastguard Worker*/
161*58b9f456SAndroid Build Coastguard Worker
162*58b9f456SAndroid Build Coastguard Worker#include <__config>
163*58b9f456SAndroid Build Coastguard Worker#include <version>
164*58b9f456SAndroid Build Coastguard Worker#include <ostream>
165*58b9f456SAndroid Build Coastguard Worker
166*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
167*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
168*58b9f456SAndroid Build Coastguard Worker#endif
169*58b9f456SAndroid Build Coastguard Worker
170*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS
171*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros>
172*58b9f456SAndroid Build Coastguard Worker
173*58b9f456SAndroid Build Coastguard Worker
174*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
175*58b9f456SAndroid Build Coastguard Worker
176*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
177*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_istream
178*58b9f456SAndroid Build Coastguard Worker    : virtual public basic_ios<_CharT, _Traits>
179*58b9f456SAndroid Build Coastguard Worker{
180*58b9f456SAndroid Build Coastguard Worker    streamsize __gc_;
181*58b9f456SAndroid Build Coastguard Workerpublic:
182*58b9f456SAndroid Build Coastguard Worker    // types (inherited from basic_ios (27.5.4)):
183*58b9f456SAndroid Build Coastguard Worker    typedef _CharT                         char_type;
184*58b9f456SAndroid Build Coastguard Worker    typedef _Traits                        traits_type;
185*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::int_type int_type;
186*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::pos_type pos_type;
187*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::off_type off_type;
188*58b9f456SAndroid Build Coastguard Worker
189*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.1.1 Constructor/destructor:
190*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
191*58b9f456SAndroid Build Coastguard Worker    explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) : __gc_(0)
192*58b9f456SAndroid Build Coastguard Worker    { this->init(__sb); }
193*58b9f456SAndroid Build Coastguard Worker    virtual ~basic_istream();
194*58b9f456SAndroid Build Coastguard Workerprotected:
195*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
196*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
197*58b9f456SAndroid Build Coastguard Worker    basic_istream(basic_istream&& __rhs);
198*58b9f456SAndroid Build Coastguard Worker
199*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.1.2 Assign/swap:
200*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
201*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator=(basic_istream&& __rhs);
202*58b9f456SAndroid Build Coastguard Worker#endif
203*58b9f456SAndroid Build Coastguard Worker
204*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
205*58b9f456SAndroid Build Coastguard Worker    void swap(basic_istream& __rhs) {
206*58b9f456SAndroid Build Coastguard Worker      _VSTD::swap(__gc_, __rhs.__gc_);
207*58b9f456SAndroid Build Coastguard Worker      basic_ios<char_type, traits_type>::swap(__rhs);
208*58b9f456SAndroid Build Coastguard Worker    }
209*58b9f456SAndroid Build Coastguard Worker
210*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
211*58b9f456SAndroid Build Coastguard Worker    basic_istream           (const basic_istream& __rhs) = delete;
212*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator=(const basic_istream& __rhs) = delete;
213*58b9f456SAndroid Build Coastguard Worker#endif
214*58b9f456SAndroid Build Coastguard Workerpublic:
215*58b9f456SAndroid Build Coastguard Worker
216*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.1.3 Prefix/suffix:
217*58b9f456SAndroid Build Coastguard Worker    class _LIBCPP_TEMPLATE_VIS sentry;
218*58b9f456SAndroid Build Coastguard Worker
219*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.2 Formatted input:
220*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
221*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&))
222*58b9f456SAndroid Build Coastguard Worker    { return __pf(*this); }
223*58b9f456SAndroid Build Coastguard Worker
224*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
225*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(basic_ios<char_type, traits_type>&
226*58b9f456SAndroid Build Coastguard Worker                              (*__pf)(basic_ios<char_type, traits_type>&))
227*58b9f456SAndroid Build Coastguard Worker    { __pf(*this); return *this; }
228*58b9f456SAndroid Build Coastguard Worker
229*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
230*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(ios_base& (*__pf)(ios_base&))
231*58b9f456SAndroid Build Coastguard Worker    { __pf(*this); return *this; }
232*58b9f456SAndroid Build Coastguard Worker
233*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb);
234*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(bool& __n);
235*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(short& __n);
236*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(unsigned short& __n);
237*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(int& __n);
238*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(unsigned int& __n);
239*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(long& __n);
240*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(unsigned long& __n);
241*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(long long& __n);
242*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(unsigned long long& __n);
243*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(float& __f);
244*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(double& __f);
245*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(long double& __f);
246*58b9f456SAndroid Build Coastguard Worker    basic_istream& operator>>(void*& __p);
247*58b9f456SAndroid Build Coastguard Worker
248*58b9f456SAndroid Build Coastguard Worker    // 27.7.1.3 Unformatted input:
249*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
250*58b9f456SAndroid Build Coastguard Worker    streamsize gcount() const {return __gc_;}
251*58b9f456SAndroid Build Coastguard Worker    int_type get();
252*58b9f456SAndroid Build Coastguard Worker
253*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
254*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(char_type& __c) {
255*58b9f456SAndroid Build Coastguard Worker      int_type __ch = get();
256*58b9f456SAndroid Build Coastguard Worker      if (__ch != traits_type::eof())
257*58b9f456SAndroid Build Coastguard Worker        __c = traits_type::to_char_type(__ch);
258*58b9f456SAndroid Build Coastguard Worker      return *this;
259*58b9f456SAndroid Build Coastguard Worker    }
260*58b9f456SAndroid Build Coastguard Worker
261*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
262*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(char_type* __s, streamsize __n)
263*58b9f456SAndroid Build Coastguard Worker    { return get(__s, __n, this->widen('\n')); }
264*58b9f456SAndroid Build Coastguard Worker
265*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(char_type* __s, streamsize __n, char_type __dlm);
266*58b9f456SAndroid Build Coastguard Worker
267*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
268*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(basic_streambuf<char_type, traits_type>& __sb)
269*58b9f456SAndroid Build Coastguard Worker    { return get(__sb, this->widen('\n')); }
270*58b9f456SAndroid Build Coastguard Worker
271*58b9f456SAndroid Build Coastguard Worker    basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm);
272*58b9f456SAndroid Build Coastguard Worker
273*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
274*58b9f456SAndroid Build Coastguard Worker    basic_istream& getline(char_type* __s, streamsize __n)
275*58b9f456SAndroid Build Coastguard Worker    { return getline(__s, __n, this->widen('\n')); }
276*58b9f456SAndroid Build Coastguard Worker
277*58b9f456SAndroid Build Coastguard Worker    basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
278*58b9f456SAndroid Build Coastguard Worker
279*58b9f456SAndroid Build Coastguard Worker    basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
280*58b9f456SAndroid Build Coastguard Worker    int_type peek();
281*58b9f456SAndroid Build Coastguard Worker    basic_istream& read (char_type* __s, streamsize __n);
282*58b9f456SAndroid Build Coastguard Worker    streamsize readsome(char_type* __s, streamsize __n);
283*58b9f456SAndroid Build Coastguard Worker
284*58b9f456SAndroid Build Coastguard Worker    basic_istream& putback(char_type __c);
285*58b9f456SAndroid Build Coastguard Worker    basic_istream& unget();
286*58b9f456SAndroid Build Coastguard Worker    int sync();
287*58b9f456SAndroid Build Coastguard Worker
288*58b9f456SAndroid Build Coastguard Worker    pos_type tellg();
289*58b9f456SAndroid Build Coastguard Worker    basic_istream& seekg(pos_type __pos);
290*58b9f456SAndroid Build Coastguard Worker    basic_istream& seekg(off_type __off, ios_base::seekdir __dir);
291*58b9f456SAndroid Build Coastguard Worker};
292*58b9f456SAndroid Build Coastguard Worker
293*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
294*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry
295*58b9f456SAndroid Build Coastguard Worker{
296*58b9f456SAndroid Build Coastguard Worker    bool __ok_;
297*58b9f456SAndroid Build Coastguard Worker
298*58b9f456SAndroid Build Coastguard Worker    sentry(const sentry&); // = delete;
299*58b9f456SAndroid Build Coastguard Worker    sentry& operator=(const sentry&); // = delete;
300*58b9f456SAndroid Build Coastguard Worker
301*58b9f456SAndroid Build Coastguard Workerpublic:
302*58b9f456SAndroid Build Coastguard Worker    explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
303*58b9f456SAndroid Build Coastguard Worker//    ~sentry() = default;
304*58b9f456SAndroid Build Coastguard Worker
305*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
306*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_EXPLICIT
307*58b9f456SAndroid Build Coastguard Worker        operator bool() const {return __ok_;}
308*58b9f456SAndroid Build Coastguard Worker};
309*58b9f456SAndroid Build Coastguard Worker
310*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
311*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is,
312*58b9f456SAndroid Build Coastguard Worker                                               bool __noskipws)
313*58b9f456SAndroid Build Coastguard Worker    : __ok_(false)
314*58b9f456SAndroid Build Coastguard Worker{
315*58b9f456SAndroid Build Coastguard Worker    if (__is.good())
316*58b9f456SAndroid Build Coastguard Worker    {
317*58b9f456SAndroid Build Coastguard Worker        if (__is.tie())
318*58b9f456SAndroid Build Coastguard Worker            __is.tie()->flush();
319*58b9f456SAndroid Build Coastguard Worker        if (!__noskipws && (__is.flags() & ios_base::skipws))
320*58b9f456SAndroid Build Coastguard Worker        {
321*58b9f456SAndroid Build Coastguard Worker            typedef istreambuf_iterator<_CharT, _Traits> _Ip;
322*58b9f456SAndroid Build Coastguard Worker            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
323*58b9f456SAndroid Build Coastguard Worker            _Ip __i(__is);
324*58b9f456SAndroid Build Coastguard Worker            _Ip __eof;
325*58b9f456SAndroid Build Coastguard Worker            for (; __i != __eof; ++__i)
326*58b9f456SAndroid Build Coastguard Worker                if (!__ct.is(__ct.space, *__i))
327*58b9f456SAndroid Build Coastguard Worker                    break;
328*58b9f456SAndroid Build Coastguard Worker            if (__i == __eof)
329*58b9f456SAndroid Build Coastguard Worker                __is.setstate(ios_base::failbit | ios_base::eofbit);
330*58b9f456SAndroid Build Coastguard Worker        }
331*58b9f456SAndroid Build Coastguard Worker        __ok_ = __is.good();
332*58b9f456SAndroid Build Coastguard Worker    }
333*58b9f456SAndroid Build Coastguard Worker    else
334*58b9f456SAndroid Build Coastguard Worker        __is.setstate(ios_base::failbit);
335*58b9f456SAndroid Build Coastguard Worker}
336*58b9f456SAndroid Build Coastguard Worker
337*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
338*58b9f456SAndroid Build Coastguard Worker
339*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
340*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
341*58b9f456SAndroid Build Coastguard Worker    : __gc_(__rhs.__gc_)
342*58b9f456SAndroid Build Coastguard Worker{
343*58b9f456SAndroid Build Coastguard Worker    __rhs.__gc_ = 0;
344*58b9f456SAndroid Build Coastguard Worker    this->move(__rhs);
345*58b9f456SAndroid Build Coastguard Worker}
346*58b9f456SAndroid Build Coastguard Worker
347*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
348*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
349*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
350*58b9f456SAndroid Build Coastguard Worker{
351*58b9f456SAndroid Build Coastguard Worker    swap(__rhs);
352*58b9f456SAndroid Build Coastguard Worker    return *this;
353*58b9f456SAndroid Build Coastguard Worker}
354*58b9f456SAndroid Build Coastguard Worker
355*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
356*58b9f456SAndroid Build Coastguard Worker
357*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
358*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::~basic_istream()
359*58b9f456SAndroid Build Coastguard Worker{
360*58b9f456SAndroid Build Coastguard Worker}
361*58b9f456SAndroid Build Coastguard Worker
362*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _CharT, class _Traits>
363*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
364*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
365*58b9f456SAndroid Build Coastguard Worker__input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
366*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
367*58b9f456SAndroid Build Coastguard Worker    try
368*58b9f456SAndroid Build Coastguard Worker    {
369*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
370*58b9f456SAndroid Build Coastguard Worker        typename basic_istream<_CharT, _Traits>::sentry __s(__is);
371*58b9f456SAndroid Build Coastguard Worker        if (__s)
372*58b9f456SAndroid Build Coastguard Worker        {
373*58b9f456SAndroid Build Coastguard Worker            typedef istreambuf_iterator<_CharT, _Traits> _Ip;
374*58b9f456SAndroid Build Coastguard Worker            typedef num_get<_CharT, _Ip> _Fp;
375*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
376*58b9f456SAndroid Build Coastguard Worker            use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __err, __n);
377*58b9f456SAndroid Build Coastguard Worker            __is.setstate(__err);
378*58b9f456SAndroid Build Coastguard Worker        }
379*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
380*58b9f456SAndroid Build Coastguard Worker    }
381*58b9f456SAndroid Build Coastguard Worker    catch (...)
382*58b9f456SAndroid Build Coastguard Worker    {
383*58b9f456SAndroid Build Coastguard Worker        __is.__set_badbit_and_consider_rethrow();
384*58b9f456SAndroid Build Coastguard Worker    }
385*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
386*58b9f456SAndroid Build Coastguard Worker    return __is;
387*58b9f456SAndroid Build Coastguard Worker}
388*58b9f456SAndroid Build Coastguard Worker
389*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
390*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
391*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
392*58b9f456SAndroid Build Coastguard Worker{
393*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<unsigned short>(*this, __n);
394*58b9f456SAndroid Build Coastguard Worker}
395*58b9f456SAndroid Build Coastguard Worker
396*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
397*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
398*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(unsigned int& __n)
399*58b9f456SAndroid Build Coastguard Worker{
400*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<unsigned int>(*this, __n);
401*58b9f456SAndroid Build Coastguard Worker}
402*58b9f456SAndroid Build Coastguard Worker
403*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
404*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
405*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(long& __n)
406*58b9f456SAndroid Build Coastguard Worker{
407*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<long>(*this, __n);
408*58b9f456SAndroid Build Coastguard Worker}
409*58b9f456SAndroid Build Coastguard Worker
410*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
411*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
412*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(unsigned long& __n)
413*58b9f456SAndroid Build Coastguard Worker{
414*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<unsigned long>(*this, __n);
415*58b9f456SAndroid Build Coastguard Worker}
416*58b9f456SAndroid Build Coastguard Worker
417*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
418*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
419*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(long long& __n)
420*58b9f456SAndroid Build Coastguard Worker{
421*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<long long>(*this, __n);
422*58b9f456SAndroid Build Coastguard Worker}
423*58b9f456SAndroid Build Coastguard Worker
424*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
425*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
426*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n)
427*58b9f456SAndroid Build Coastguard Worker{
428*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<unsigned long long>(*this, __n);
429*58b9f456SAndroid Build Coastguard Worker}
430*58b9f456SAndroid Build Coastguard Worker
431*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
432*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
433*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(float& __n)
434*58b9f456SAndroid Build Coastguard Worker{
435*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<float>(*this, __n);
436*58b9f456SAndroid Build Coastguard Worker}
437*58b9f456SAndroid Build Coastguard Worker
438*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
439*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
440*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(double& __n)
441*58b9f456SAndroid Build Coastguard Worker{
442*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<double>(*this, __n);
443*58b9f456SAndroid Build Coastguard Worker}
444*58b9f456SAndroid Build Coastguard Worker
445*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
446*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
447*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(long double& __n)
448*58b9f456SAndroid Build Coastguard Worker{
449*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<long double>(*this, __n);
450*58b9f456SAndroid Build Coastguard Worker}
451*58b9f456SAndroid Build Coastguard Worker
452*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
453*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
454*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(bool& __n)
455*58b9f456SAndroid Build Coastguard Worker{
456*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<bool>(*this, __n);
457*58b9f456SAndroid Build Coastguard Worker}
458*58b9f456SAndroid Build Coastguard Worker
459*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
460*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
461*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(void*& __n)
462*58b9f456SAndroid Build Coastguard Worker{
463*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic<void*>(*this, __n);
464*58b9f456SAndroid Build Coastguard Worker}
465*58b9f456SAndroid Build Coastguard Worker
466*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _CharT, class _Traits>
467*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
468*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
469*58b9f456SAndroid Build Coastguard Worker__input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
470*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
471*58b9f456SAndroid Build Coastguard Worker    try
472*58b9f456SAndroid Build Coastguard Worker    {
473*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
474*58b9f456SAndroid Build Coastguard Worker        typename basic_istream<_CharT, _Traits>::sentry __s(__is);
475*58b9f456SAndroid Build Coastguard Worker        if (__s)
476*58b9f456SAndroid Build Coastguard Worker        {
477*58b9f456SAndroid Build Coastguard Worker            typedef istreambuf_iterator<_CharT, _Traits> _Ip;
478*58b9f456SAndroid Build Coastguard Worker            typedef num_get<_CharT, _Ip> _Fp;
479*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
480*58b9f456SAndroid Build Coastguard Worker            long __temp;
481*58b9f456SAndroid Build Coastguard Worker            use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __err, __temp);
482*58b9f456SAndroid Build Coastguard Worker            if (__temp < numeric_limits<_Tp>::min())
483*58b9f456SAndroid Build Coastguard Worker            {
484*58b9f456SAndroid Build Coastguard Worker                __err |= ios_base::failbit;
485*58b9f456SAndroid Build Coastguard Worker                __n = numeric_limits<_Tp>::min();
486*58b9f456SAndroid Build Coastguard Worker            }
487*58b9f456SAndroid Build Coastguard Worker            else if (__temp > numeric_limits<_Tp>::max())
488*58b9f456SAndroid Build Coastguard Worker            {
489*58b9f456SAndroid Build Coastguard Worker                __err |= ios_base::failbit;
490*58b9f456SAndroid Build Coastguard Worker                __n = numeric_limits<_Tp>::max();
491*58b9f456SAndroid Build Coastguard Worker            }
492*58b9f456SAndroid Build Coastguard Worker            else
493*58b9f456SAndroid Build Coastguard Worker                __n = static_cast<_Tp>(__temp);
494*58b9f456SAndroid Build Coastguard Worker            __is.setstate(__err);
495*58b9f456SAndroid Build Coastguard Worker        }
496*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
497*58b9f456SAndroid Build Coastguard Worker    }
498*58b9f456SAndroid Build Coastguard Worker    catch (...)
499*58b9f456SAndroid Build Coastguard Worker    {
500*58b9f456SAndroid Build Coastguard Worker        __is.__set_badbit_and_consider_rethrow();
501*58b9f456SAndroid Build Coastguard Worker    }
502*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
503*58b9f456SAndroid Build Coastguard Worker    return __is;
504*58b9f456SAndroid Build Coastguard Worker}
505*58b9f456SAndroid Build Coastguard Worker
506*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
507*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
508*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(short& __n)
509*58b9f456SAndroid Build Coastguard Worker{
510*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic_with_numeric_limits<short>(*this, __n);
511*58b9f456SAndroid Build Coastguard Worker}
512*58b9f456SAndroid Build Coastguard Worker
513*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
514*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
515*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(int& __n)
516*58b9f456SAndroid Build Coastguard Worker{
517*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_arithmetic_with_numeric_limits<int>(*this, __n);
518*58b9f456SAndroid Build Coastguard Worker}
519*58b9f456SAndroid Build Coastguard Worker
520*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
521*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
522*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
523*58b9f456SAndroid Build Coastguard Worker__input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
524*58b9f456SAndroid Build Coastguard Worker{
525*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
526*58b9f456SAndroid Build Coastguard Worker    try
527*58b9f456SAndroid Build Coastguard Worker    {
528*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
529*58b9f456SAndroid Build Coastguard Worker        typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
530*58b9f456SAndroid Build Coastguard Worker        if (__sen)
531*58b9f456SAndroid Build Coastguard Worker        {
532*58b9f456SAndroid Build Coastguard Worker            auto __s = __p;
533*58b9f456SAndroid Build Coastguard Worker            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
534*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
535*58b9f456SAndroid Build Coastguard Worker            while (__s != __p + (__n-1))
536*58b9f456SAndroid Build Coastguard Worker            {
537*58b9f456SAndroid Build Coastguard Worker                typename _Traits::int_type __i = __is.rdbuf()->sgetc();
538*58b9f456SAndroid Build Coastguard Worker                if (_Traits::eq_int_type(__i, _Traits::eof()))
539*58b9f456SAndroid Build Coastguard Worker                {
540*58b9f456SAndroid Build Coastguard Worker                   __err |= ios_base::eofbit;
541*58b9f456SAndroid Build Coastguard Worker                   break;
542*58b9f456SAndroid Build Coastguard Worker                }
543*58b9f456SAndroid Build Coastguard Worker                _CharT __ch = _Traits::to_char_type(__i);
544*58b9f456SAndroid Build Coastguard Worker                if (__ct.is(__ct.space, __ch))
545*58b9f456SAndroid Build Coastguard Worker                    break;
546*58b9f456SAndroid Build Coastguard Worker                *__s++ = __ch;
547*58b9f456SAndroid Build Coastguard Worker                 __is.rdbuf()->sbumpc();
548*58b9f456SAndroid Build Coastguard Worker            }
549*58b9f456SAndroid Build Coastguard Worker            *__s = _CharT();
550*58b9f456SAndroid Build Coastguard Worker            __is.width(0);
551*58b9f456SAndroid Build Coastguard Worker            if (__s == __p)
552*58b9f456SAndroid Build Coastguard Worker               __err |= ios_base::failbit;
553*58b9f456SAndroid Build Coastguard Worker            __is.setstate(__err);
554*58b9f456SAndroid Build Coastguard Worker        }
555*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
556*58b9f456SAndroid Build Coastguard Worker    }
557*58b9f456SAndroid Build Coastguard Worker    catch (...)
558*58b9f456SAndroid Build Coastguard Worker    {
559*58b9f456SAndroid Build Coastguard Worker        __is.__set_badbit_and_consider_rethrow();
560*58b9f456SAndroid Build Coastguard Worker    }
561*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
562*58b9f456SAndroid Build Coastguard Worker    return __is;
563*58b9f456SAndroid Build Coastguard Worker}
564*58b9f456SAndroid Build Coastguard Worker
565*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17
566*58b9f456SAndroid Build Coastguard Worker
567*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, size_t _Np>
568*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
569*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
570*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<_CharT, _Traits>& __is, _CharT (&__buf)[_Np])
571*58b9f456SAndroid Build Coastguard Worker{
572*58b9f456SAndroid Build Coastguard Worker    auto __n = _Np;
573*58b9f456SAndroid Build Coastguard Worker    if (__is.width() > 0)
574*58b9f456SAndroid Build Coastguard Worker        __n = _VSTD::min(size_t(__is.width()), _Np);
575*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_c_string(__is, __buf, __n);
576*58b9f456SAndroid Build Coastguard Worker}
577*58b9f456SAndroid Build Coastguard Worker
578*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits, size_t _Np>
579*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
580*58b9f456SAndroid Build Coastguard Workerbasic_istream<char, _Traits>&
581*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<char, _Traits>& __is, unsigned char (&__buf)[_Np])
582*58b9f456SAndroid Build Coastguard Worker{
583*58b9f456SAndroid Build Coastguard Worker    return __is >> (char(&)[_Np])__buf;
584*58b9f456SAndroid Build Coastguard Worker}
585*58b9f456SAndroid Build Coastguard Worker
586*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits, size_t _Np>
587*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
588*58b9f456SAndroid Build Coastguard Workerbasic_istream<char, _Traits>&
589*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<char, _Traits>& __is, signed char (&__buf)[_Np])
590*58b9f456SAndroid Build Coastguard Worker{
591*58b9f456SAndroid Build Coastguard Worker    return __is >> (char(&)[_Np])__buf;
592*58b9f456SAndroid Build Coastguard Worker}
593*58b9f456SAndroid Build Coastguard Worker
594*58b9f456SAndroid Build Coastguard Worker#else
595*58b9f456SAndroid Build Coastguard Worker
596*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
597*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
598*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
599*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s)
600*58b9f456SAndroid Build Coastguard Worker{
601*58b9f456SAndroid Build Coastguard Worker    streamsize __n = __is.width();
602*58b9f456SAndroid Build Coastguard Worker    if (__n <= 0)
603*58b9f456SAndroid Build Coastguard Worker        __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1;
604*58b9f456SAndroid Build Coastguard Worker    return _VSTD::__input_c_string(__is, __s, size_t(__n));
605*58b9f456SAndroid Build Coastguard Worker}
606*58b9f456SAndroid Build Coastguard Worker
607*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
608*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
609*58b9f456SAndroid Build Coastguard Workerbasic_istream<char, _Traits>&
610*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<char, _Traits>& __is, unsigned char* __s)
611*58b9f456SAndroid Build Coastguard Worker{
612*58b9f456SAndroid Build Coastguard Worker    return __is >> (char*)__s;
613*58b9f456SAndroid Build Coastguard Worker}
614*58b9f456SAndroid Build Coastguard Worker
615*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
616*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
617*58b9f456SAndroid Build Coastguard Workerbasic_istream<char, _Traits>&
618*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<char, _Traits>& __is, signed char* __s)
619*58b9f456SAndroid Build Coastguard Worker{
620*58b9f456SAndroid Build Coastguard Worker    return __is >> (char*)__s;
621*58b9f456SAndroid Build Coastguard Worker}
622*58b9f456SAndroid Build Coastguard Worker
623*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_STD_VER > 17
624*58b9f456SAndroid Build Coastguard Worker
625*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
626*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
627*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
628*58b9f456SAndroid Build Coastguard Worker{
629*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
630*58b9f456SAndroid Build Coastguard Worker    try
631*58b9f456SAndroid Build Coastguard Worker    {
632*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
633*58b9f456SAndroid Build Coastguard Worker        typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
634*58b9f456SAndroid Build Coastguard Worker        if (__sen)
635*58b9f456SAndroid Build Coastguard Worker        {
636*58b9f456SAndroid Build Coastguard Worker            typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
637*58b9f456SAndroid Build Coastguard Worker            if (_Traits::eq_int_type(__i, _Traits::eof()))
638*58b9f456SAndroid Build Coastguard Worker                __is.setstate(ios_base::eofbit | ios_base::failbit);
639*58b9f456SAndroid Build Coastguard Worker            else
640*58b9f456SAndroid Build Coastguard Worker                __c = _Traits::to_char_type(__i);
641*58b9f456SAndroid Build Coastguard Worker        }
642*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
643*58b9f456SAndroid Build Coastguard Worker    }
644*58b9f456SAndroid Build Coastguard Worker    catch (...)
645*58b9f456SAndroid Build Coastguard Worker    {
646*58b9f456SAndroid Build Coastguard Worker        __is.__set_badbit_and_consider_rethrow();
647*58b9f456SAndroid Build Coastguard Worker    }
648*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
649*58b9f456SAndroid Build Coastguard Worker    return __is;
650*58b9f456SAndroid Build Coastguard Worker}
651*58b9f456SAndroid Build Coastguard Worker
652*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
653*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
654*58b9f456SAndroid Build Coastguard Workerbasic_istream<char, _Traits>&
655*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<char, _Traits>& __is, unsigned char& __c)
656*58b9f456SAndroid Build Coastguard Worker{
657*58b9f456SAndroid Build Coastguard Worker    return __is >> (char&)__c;
658*58b9f456SAndroid Build Coastguard Worker}
659*58b9f456SAndroid Build Coastguard Worker
660*58b9f456SAndroid Build Coastguard Workertemplate<class _Traits>
661*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
662*58b9f456SAndroid Build Coastguard Workerbasic_istream<char, _Traits>&
663*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<char, _Traits>& __is, signed char& __c)
664*58b9f456SAndroid Build Coastguard Worker{
665*58b9f456SAndroid Build Coastguard Worker    return __is >> (char&)__c;
666*58b9f456SAndroid Build Coastguard Worker}
667*58b9f456SAndroid Build Coastguard Worker
668*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
669*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
670*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb)
671*58b9f456SAndroid Build Coastguard Worker{
672*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
673*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
674*58b9f456SAndroid Build Coastguard Worker    try
675*58b9f456SAndroid Build Coastguard Worker    {
676*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
677*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this, true);
678*58b9f456SAndroid Build Coastguard Worker        if (__s)
679*58b9f456SAndroid Build Coastguard Worker        {
680*58b9f456SAndroid Build Coastguard Worker            if (__sb)
681*58b9f456SAndroid Build Coastguard Worker            {
682*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
683*58b9f456SAndroid Build Coastguard Worker                try
684*58b9f456SAndroid Build Coastguard Worker                {
685*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
686*58b9f456SAndroid Build Coastguard Worker                    ios_base::iostate __err = ios_base::goodbit;
687*58b9f456SAndroid Build Coastguard Worker                    while (true)
688*58b9f456SAndroid Build Coastguard Worker                    {
689*58b9f456SAndroid Build Coastguard Worker                        typename traits_type::int_type __i = this->rdbuf()->sgetc();
690*58b9f456SAndroid Build Coastguard Worker                        if (traits_type::eq_int_type(__i, _Traits::eof()))
691*58b9f456SAndroid Build Coastguard Worker                        {
692*58b9f456SAndroid Build Coastguard Worker                           __err |= ios_base::eofbit;
693*58b9f456SAndroid Build Coastguard Worker                           break;
694*58b9f456SAndroid Build Coastguard Worker                        }
695*58b9f456SAndroid Build Coastguard Worker                        if (traits_type::eq_int_type(
696*58b9f456SAndroid Build Coastguard Worker                                __sb->sputc(traits_type::to_char_type(__i)),
697*58b9f456SAndroid Build Coastguard Worker                                traits_type::eof()))
698*58b9f456SAndroid Build Coastguard Worker                            break;
699*58b9f456SAndroid Build Coastguard Worker                        ++__gc_;
700*58b9f456SAndroid Build Coastguard Worker                        this->rdbuf()->sbumpc();
701*58b9f456SAndroid Build Coastguard Worker                    }
702*58b9f456SAndroid Build Coastguard Worker                    if (__gc_ == 0)
703*58b9f456SAndroid Build Coastguard Worker                       __err |= ios_base::failbit;
704*58b9f456SAndroid Build Coastguard Worker                    this->setstate(__err);
705*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
706*58b9f456SAndroid Build Coastguard Worker                }
707*58b9f456SAndroid Build Coastguard Worker                catch (...)
708*58b9f456SAndroid Build Coastguard Worker                {
709*58b9f456SAndroid Build Coastguard Worker                    if (__gc_ == 0)
710*58b9f456SAndroid Build Coastguard Worker                        this->__set_failbit_and_consider_rethrow();
711*58b9f456SAndroid Build Coastguard Worker                }
712*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
713*58b9f456SAndroid Build Coastguard Worker            }
714*58b9f456SAndroid Build Coastguard Worker            else
715*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::failbit);
716*58b9f456SAndroid Build Coastguard Worker        }
717*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
718*58b9f456SAndroid Build Coastguard Worker    }
719*58b9f456SAndroid Build Coastguard Worker    catch (...)
720*58b9f456SAndroid Build Coastguard Worker    {
721*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
722*58b9f456SAndroid Build Coastguard Worker    }
723*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
724*58b9f456SAndroid Build Coastguard Worker    return *this;
725*58b9f456SAndroid Build Coastguard Worker}
726*58b9f456SAndroid Build Coastguard Worker
727*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
728*58b9f456SAndroid Build Coastguard Workertypename basic_istream<_CharT, _Traits>::int_type
729*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::get()
730*58b9f456SAndroid Build Coastguard Worker{
731*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
732*58b9f456SAndroid Build Coastguard Worker    int_type __r = traits_type::eof();
733*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
734*58b9f456SAndroid Build Coastguard Worker    try
735*58b9f456SAndroid Build Coastguard Worker    {
736*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
737*58b9f456SAndroid Build Coastguard Worker        sentry __s(*this, true);
738*58b9f456SAndroid Build Coastguard Worker        if (__s)
739*58b9f456SAndroid Build Coastguard Worker        {
740*58b9f456SAndroid Build Coastguard Worker            __r = this->rdbuf()->sbumpc();
741*58b9f456SAndroid Build Coastguard Worker            if (traits_type::eq_int_type(__r, traits_type::eof()))
742*58b9f456SAndroid Build Coastguard Worker               this->setstate(ios_base::failbit | ios_base::eofbit);
743*58b9f456SAndroid Build Coastguard Worker            else
744*58b9f456SAndroid Build Coastguard Worker                __gc_ = 1;
745*58b9f456SAndroid Build Coastguard Worker        }
746*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
747*58b9f456SAndroid Build Coastguard Worker    }
748*58b9f456SAndroid Build Coastguard Worker    catch (...)
749*58b9f456SAndroid Build Coastguard Worker    {
750*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
751*58b9f456SAndroid Build Coastguard Worker    }
752*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
753*58b9f456SAndroid Build Coastguard Worker    return __r;
754*58b9f456SAndroid Build Coastguard Worker}
755*58b9f456SAndroid Build Coastguard Worker
756*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
757*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
758*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm)
759*58b9f456SAndroid Build Coastguard Worker{
760*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
761*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
762*58b9f456SAndroid Build Coastguard Worker    try
763*58b9f456SAndroid Build Coastguard Worker    {
764*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
765*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
766*58b9f456SAndroid Build Coastguard Worker        if (__sen)
767*58b9f456SAndroid Build Coastguard Worker        {
768*58b9f456SAndroid Build Coastguard Worker            if (__n > 0)
769*58b9f456SAndroid Build Coastguard Worker            {
770*58b9f456SAndroid Build Coastguard Worker                ios_base::iostate __err = ios_base::goodbit;
771*58b9f456SAndroid Build Coastguard Worker                while (__gc_ < __n-1)
772*58b9f456SAndroid Build Coastguard Worker                {
773*58b9f456SAndroid Build Coastguard Worker                    int_type __i = this->rdbuf()->sgetc();
774*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq_int_type(__i, traits_type::eof()))
775*58b9f456SAndroid Build Coastguard Worker                    {
776*58b9f456SAndroid Build Coastguard Worker                       __err |= ios_base::eofbit;
777*58b9f456SAndroid Build Coastguard Worker                       break;
778*58b9f456SAndroid Build Coastguard Worker                    }
779*58b9f456SAndroid Build Coastguard Worker                    char_type __ch = traits_type::to_char_type(__i);
780*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq(__ch, __dlm))
781*58b9f456SAndroid Build Coastguard Worker                        break;
782*58b9f456SAndroid Build Coastguard Worker                    *__s++ = __ch;
783*58b9f456SAndroid Build Coastguard Worker                    ++__gc_;
784*58b9f456SAndroid Build Coastguard Worker                     this->rdbuf()->sbumpc();
785*58b9f456SAndroid Build Coastguard Worker                }
786*58b9f456SAndroid Build Coastguard Worker                if (__gc_ == 0)
787*58b9f456SAndroid Build Coastguard Worker                   __err |= ios_base::failbit;
788*58b9f456SAndroid Build Coastguard Worker                this->setstate(__err);
789*58b9f456SAndroid Build Coastguard Worker            }
790*58b9f456SAndroid Build Coastguard Worker            else
791*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::failbit);
792*58b9f456SAndroid Build Coastguard Worker        }
793*58b9f456SAndroid Build Coastguard Worker        if (__n > 0)
794*58b9f456SAndroid Build Coastguard Worker            *__s = char_type();
795*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
796*58b9f456SAndroid Build Coastguard Worker    }
797*58b9f456SAndroid Build Coastguard Worker    catch (...)
798*58b9f456SAndroid Build Coastguard Worker    {
799*58b9f456SAndroid Build Coastguard Worker        if (__n > 0)
800*58b9f456SAndroid Build Coastguard Worker            *__s = char_type();
801*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
802*58b9f456SAndroid Build Coastguard Worker    }
803*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
804*58b9f456SAndroid Build Coastguard Worker    return *this;
805*58b9f456SAndroid Build Coastguard Worker}
806*58b9f456SAndroid Build Coastguard Worker
807*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
808*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
809*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb,
810*58b9f456SAndroid Build Coastguard Worker                                    char_type __dlm)
811*58b9f456SAndroid Build Coastguard Worker{
812*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
813*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
814*58b9f456SAndroid Build Coastguard Worker    try
815*58b9f456SAndroid Build Coastguard Worker    {
816*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
817*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
818*58b9f456SAndroid Build Coastguard Worker        if (__sen)
819*58b9f456SAndroid Build Coastguard Worker        {
820*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
821*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
822*58b9f456SAndroid Build Coastguard Worker            try
823*58b9f456SAndroid Build Coastguard Worker            {
824*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
825*58b9f456SAndroid Build Coastguard Worker                while (true)
826*58b9f456SAndroid Build Coastguard Worker                {
827*58b9f456SAndroid Build Coastguard Worker                    typename traits_type::int_type __i = this->rdbuf()->sgetc();
828*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq_int_type(__i, traits_type::eof()))
829*58b9f456SAndroid Build Coastguard Worker                    {
830*58b9f456SAndroid Build Coastguard Worker                       __err |= ios_base::eofbit;
831*58b9f456SAndroid Build Coastguard Worker                       break;
832*58b9f456SAndroid Build Coastguard Worker                    }
833*58b9f456SAndroid Build Coastguard Worker                    char_type __ch = traits_type::to_char_type(__i);
834*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq(__ch, __dlm))
835*58b9f456SAndroid Build Coastguard Worker                        break;
836*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
837*58b9f456SAndroid Build Coastguard Worker                        break;
838*58b9f456SAndroid Build Coastguard Worker                    ++__gc_;
839*58b9f456SAndroid Build Coastguard Worker                    this->rdbuf()->sbumpc();
840*58b9f456SAndroid Build Coastguard Worker                }
841*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
842*58b9f456SAndroid Build Coastguard Worker            }
843*58b9f456SAndroid Build Coastguard Worker            catch (...)
844*58b9f456SAndroid Build Coastguard Worker            {
845*58b9f456SAndroid Build Coastguard Worker            }
846*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
847*58b9f456SAndroid Build Coastguard Worker            if (__gc_ == 0)
848*58b9f456SAndroid Build Coastguard Worker               __err |= ios_base::failbit;
849*58b9f456SAndroid Build Coastguard Worker            this->setstate(__err);
850*58b9f456SAndroid Build Coastguard Worker        }
851*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
852*58b9f456SAndroid Build Coastguard Worker    }
853*58b9f456SAndroid Build Coastguard Worker    catch (...)
854*58b9f456SAndroid Build Coastguard Worker    {
855*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
856*58b9f456SAndroid Build Coastguard Worker    }
857*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
858*58b9f456SAndroid Build Coastguard Worker    return *this;
859*58b9f456SAndroid Build Coastguard Worker}
860*58b9f456SAndroid Build Coastguard Worker
861*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
862*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
863*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm)
864*58b9f456SAndroid Build Coastguard Worker{
865*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
866*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
867*58b9f456SAndroid Build Coastguard Worker    try
868*58b9f456SAndroid Build Coastguard Worker    {
869*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
870*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
871*58b9f456SAndroid Build Coastguard Worker        if (__sen)
872*58b9f456SAndroid Build Coastguard Worker        {
873*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
874*58b9f456SAndroid Build Coastguard Worker            while (true)
875*58b9f456SAndroid Build Coastguard Worker            {
876*58b9f456SAndroid Build Coastguard Worker                typename traits_type::int_type __i = this->rdbuf()->sgetc();
877*58b9f456SAndroid Build Coastguard Worker                if (traits_type::eq_int_type(__i, traits_type::eof()))
878*58b9f456SAndroid Build Coastguard Worker                {
879*58b9f456SAndroid Build Coastguard Worker                   __err |= ios_base::eofbit;
880*58b9f456SAndroid Build Coastguard Worker                   break;
881*58b9f456SAndroid Build Coastguard Worker                }
882*58b9f456SAndroid Build Coastguard Worker                char_type __ch = traits_type::to_char_type(__i);
883*58b9f456SAndroid Build Coastguard Worker                if (traits_type::eq(__ch, __dlm))
884*58b9f456SAndroid Build Coastguard Worker                {
885*58b9f456SAndroid Build Coastguard Worker                    this->rdbuf()->sbumpc();
886*58b9f456SAndroid Build Coastguard Worker                    ++__gc_;
887*58b9f456SAndroid Build Coastguard Worker                    break;
888*58b9f456SAndroid Build Coastguard Worker                }
889*58b9f456SAndroid Build Coastguard Worker                if (__gc_ >= __n-1)
890*58b9f456SAndroid Build Coastguard Worker                {
891*58b9f456SAndroid Build Coastguard Worker                    __err |= ios_base::failbit;
892*58b9f456SAndroid Build Coastguard Worker                    break;
893*58b9f456SAndroid Build Coastguard Worker                }
894*58b9f456SAndroid Build Coastguard Worker                *__s++ = __ch;
895*58b9f456SAndroid Build Coastguard Worker                this->rdbuf()->sbumpc();
896*58b9f456SAndroid Build Coastguard Worker                ++__gc_;
897*58b9f456SAndroid Build Coastguard Worker            }
898*58b9f456SAndroid Build Coastguard Worker            if (__gc_ == 0)
899*58b9f456SAndroid Build Coastguard Worker               __err |= ios_base::failbit;
900*58b9f456SAndroid Build Coastguard Worker            this->setstate(__err);
901*58b9f456SAndroid Build Coastguard Worker        }
902*58b9f456SAndroid Build Coastguard Worker        if (__n > 0)
903*58b9f456SAndroid Build Coastguard Worker            *__s = char_type();
904*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
905*58b9f456SAndroid Build Coastguard Worker    }
906*58b9f456SAndroid Build Coastguard Worker    catch (...)
907*58b9f456SAndroid Build Coastguard Worker    {
908*58b9f456SAndroid Build Coastguard Worker        if (__n > 0)
909*58b9f456SAndroid Build Coastguard Worker            *__s = char_type();
910*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
911*58b9f456SAndroid Build Coastguard Worker    }
912*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
913*58b9f456SAndroid Build Coastguard Worker    return *this;
914*58b9f456SAndroid Build Coastguard Worker}
915*58b9f456SAndroid Build Coastguard Worker
916*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
917*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
918*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
919*58b9f456SAndroid Build Coastguard Worker{
920*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
921*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
922*58b9f456SAndroid Build Coastguard Worker    try
923*58b9f456SAndroid Build Coastguard Worker    {
924*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
925*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
926*58b9f456SAndroid Build Coastguard Worker        if (__sen)
927*58b9f456SAndroid Build Coastguard Worker        {
928*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
929*58b9f456SAndroid Build Coastguard Worker            if (__n == numeric_limits<streamsize>::max())
930*58b9f456SAndroid Build Coastguard Worker            {
931*58b9f456SAndroid Build Coastguard Worker                while (true)
932*58b9f456SAndroid Build Coastguard Worker                {
933*58b9f456SAndroid Build Coastguard Worker                    typename traits_type::int_type __i = this->rdbuf()->sbumpc();
934*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq_int_type(__i, traits_type::eof()))
935*58b9f456SAndroid Build Coastguard Worker                    {
936*58b9f456SAndroid Build Coastguard Worker                       __err |= ios_base::eofbit;
937*58b9f456SAndroid Build Coastguard Worker                       break;
938*58b9f456SAndroid Build Coastguard Worker                    }
939*58b9f456SAndroid Build Coastguard Worker                    ++__gc_;
940*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq_int_type(__i, __dlm))
941*58b9f456SAndroid Build Coastguard Worker                        break;
942*58b9f456SAndroid Build Coastguard Worker                }
943*58b9f456SAndroid Build Coastguard Worker            }
944*58b9f456SAndroid Build Coastguard Worker            else
945*58b9f456SAndroid Build Coastguard Worker            {
946*58b9f456SAndroid Build Coastguard Worker                while (__gc_ < __n)
947*58b9f456SAndroid Build Coastguard Worker                {
948*58b9f456SAndroid Build Coastguard Worker                    typename traits_type::int_type __i = this->rdbuf()->sbumpc();
949*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq_int_type(__i, traits_type::eof()))
950*58b9f456SAndroid Build Coastguard Worker                    {
951*58b9f456SAndroid Build Coastguard Worker                       __err |= ios_base::eofbit;
952*58b9f456SAndroid Build Coastguard Worker                       break;
953*58b9f456SAndroid Build Coastguard Worker                    }
954*58b9f456SAndroid Build Coastguard Worker                    ++__gc_;
955*58b9f456SAndroid Build Coastguard Worker                    if (traits_type::eq_int_type(__i, __dlm))
956*58b9f456SAndroid Build Coastguard Worker                        break;
957*58b9f456SAndroid Build Coastguard Worker                }
958*58b9f456SAndroid Build Coastguard Worker            }
959*58b9f456SAndroid Build Coastguard Worker            this->setstate(__err);
960*58b9f456SAndroid Build Coastguard Worker        }
961*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
962*58b9f456SAndroid Build Coastguard Worker    }
963*58b9f456SAndroid Build Coastguard Worker    catch (...)
964*58b9f456SAndroid Build Coastguard Worker    {
965*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
966*58b9f456SAndroid Build Coastguard Worker    }
967*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
968*58b9f456SAndroid Build Coastguard Worker    return *this;
969*58b9f456SAndroid Build Coastguard Worker}
970*58b9f456SAndroid Build Coastguard Worker
971*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
972*58b9f456SAndroid Build Coastguard Workertypename basic_istream<_CharT, _Traits>::int_type
973*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::peek()
974*58b9f456SAndroid Build Coastguard Worker{
975*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
976*58b9f456SAndroid Build Coastguard Worker    int_type __r = traits_type::eof();
977*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
978*58b9f456SAndroid Build Coastguard Worker    try
979*58b9f456SAndroid Build Coastguard Worker    {
980*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
981*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
982*58b9f456SAndroid Build Coastguard Worker        if (__sen)
983*58b9f456SAndroid Build Coastguard Worker        {
984*58b9f456SAndroid Build Coastguard Worker            __r = this->rdbuf()->sgetc();
985*58b9f456SAndroid Build Coastguard Worker            if (traits_type::eq_int_type(__r, traits_type::eof()))
986*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::eofbit);
987*58b9f456SAndroid Build Coastguard Worker        }
988*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
989*58b9f456SAndroid Build Coastguard Worker    }
990*58b9f456SAndroid Build Coastguard Worker    catch (...)
991*58b9f456SAndroid Build Coastguard Worker    {
992*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
993*58b9f456SAndroid Build Coastguard Worker    }
994*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
995*58b9f456SAndroid Build Coastguard Worker    return __r;
996*58b9f456SAndroid Build Coastguard Worker}
997*58b9f456SAndroid Build Coastguard Worker
998*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
999*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1000*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
1001*58b9f456SAndroid Build Coastguard Worker{
1002*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
1003*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1004*58b9f456SAndroid Build Coastguard Worker    try
1005*58b9f456SAndroid Build Coastguard Worker    {
1006*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1007*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
1008*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1009*58b9f456SAndroid Build Coastguard Worker        {
1010*58b9f456SAndroid Build Coastguard Worker            __gc_ = this->rdbuf()->sgetn(__s, __n);
1011*58b9f456SAndroid Build Coastguard Worker            if (__gc_ != __n)
1012*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::failbit | ios_base::eofbit);
1013*58b9f456SAndroid Build Coastguard Worker        }
1014*58b9f456SAndroid Build Coastguard Worker        else
1015*58b9f456SAndroid Build Coastguard Worker            this->setstate(ios_base::failbit);
1016*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1017*58b9f456SAndroid Build Coastguard Worker    }
1018*58b9f456SAndroid Build Coastguard Worker    catch (...)
1019*58b9f456SAndroid Build Coastguard Worker    {
1020*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
1021*58b9f456SAndroid Build Coastguard Worker    }
1022*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1023*58b9f456SAndroid Build Coastguard Worker    return *this;
1024*58b9f456SAndroid Build Coastguard Worker}
1025*58b9f456SAndroid Build Coastguard Worker
1026*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
1027*58b9f456SAndroid Build Coastguard Workerstreamsize
1028*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
1029*58b9f456SAndroid Build Coastguard Worker{
1030*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
1031*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1032*58b9f456SAndroid Build Coastguard Worker    try
1033*58b9f456SAndroid Build Coastguard Worker    {
1034*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1035*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
1036*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1037*58b9f456SAndroid Build Coastguard Worker        {
1038*58b9f456SAndroid Build Coastguard Worker            streamsize __c = this->rdbuf()->in_avail();
1039*58b9f456SAndroid Build Coastguard Worker            switch (__c)
1040*58b9f456SAndroid Build Coastguard Worker            {
1041*58b9f456SAndroid Build Coastguard Worker            case -1:
1042*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::eofbit);
1043*58b9f456SAndroid Build Coastguard Worker                break;
1044*58b9f456SAndroid Build Coastguard Worker            case 0:
1045*58b9f456SAndroid Build Coastguard Worker                break;
1046*58b9f456SAndroid Build Coastguard Worker            default:
1047*58b9f456SAndroid Build Coastguard Worker                read(__s, _VSTD::min(__c, __n));
1048*58b9f456SAndroid Build Coastguard Worker                break;
1049*58b9f456SAndroid Build Coastguard Worker            }
1050*58b9f456SAndroid Build Coastguard Worker        }
1051*58b9f456SAndroid Build Coastguard Worker        else
1052*58b9f456SAndroid Build Coastguard Worker            this->setstate(ios_base::failbit);
1053*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1054*58b9f456SAndroid Build Coastguard Worker    }
1055*58b9f456SAndroid Build Coastguard Worker    catch (...)
1056*58b9f456SAndroid Build Coastguard Worker    {
1057*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
1058*58b9f456SAndroid Build Coastguard Worker    }
1059*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1060*58b9f456SAndroid Build Coastguard Worker    return __gc_;
1061*58b9f456SAndroid Build Coastguard Worker}
1062*58b9f456SAndroid Build Coastguard Worker
1063*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
1064*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1065*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::putback(char_type __c)
1066*58b9f456SAndroid Build Coastguard Worker{
1067*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
1068*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1069*58b9f456SAndroid Build Coastguard Worker    try
1070*58b9f456SAndroid Build Coastguard Worker    {
1071*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1072*58b9f456SAndroid Build Coastguard Worker        this->clear(this->rdstate() & ~ios_base::eofbit);
1073*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
1074*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1075*58b9f456SAndroid Build Coastguard Worker        {
1076*58b9f456SAndroid Build Coastguard Worker            if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof())
1077*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit);
1078*58b9f456SAndroid Build Coastguard Worker        }
1079*58b9f456SAndroid Build Coastguard Worker        else
1080*58b9f456SAndroid Build Coastguard Worker            this->setstate(ios_base::failbit);
1081*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1082*58b9f456SAndroid Build Coastguard Worker    }
1083*58b9f456SAndroid Build Coastguard Worker    catch (...)
1084*58b9f456SAndroid Build Coastguard Worker    {
1085*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
1086*58b9f456SAndroid Build Coastguard Worker    }
1087*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1088*58b9f456SAndroid Build Coastguard Worker    return *this;
1089*58b9f456SAndroid Build Coastguard Worker}
1090*58b9f456SAndroid Build Coastguard Worker
1091*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
1092*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1093*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::unget()
1094*58b9f456SAndroid Build Coastguard Worker{
1095*58b9f456SAndroid Build Coastguard Worker    __gc_ = 0;
1096*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1097*58b9f456SAndroid Build Coastguard Worker    try
1098*58b9f456SAndroid Build Coastguard Worker    {
1099*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1100*58b9f456SAndroid Build Coastguard Worker        this->clear(this->rdstate() & ~ios_base::eofbit);
1101*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
1102*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1103*58b9f456SAndroid Build Coastguard Worker        {
1104*58b9f456SAndroid Build Coastguard Worker            if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof())
1105*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit);
1106*58b9f456SAndroid Build Coastguard Worker        }
1107*58b9f456SAndroid Build Coastguard Worker        else
1108*58b9f456SAndroid Build Coastguard Worker            this->setstate(ios_base::failbit);
1109*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1110*58b9f456SAndroid Build Coastguard Worker    }
1111*58b9f456SAndroid Build Coastguard Worker    catch (...)
1112*58b9f456SAndroid Build Coastguard Worker    {
1113*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
1114*58b9f456SAndroid Build Coastguard Worker    }
1115*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1116*58b9f456SAndroid Build Coastguard Worker    return *this;
1117*58b9f456SAndroid Build Coastguard Worker}
1118*58b9f456SAndroid Build Coastguard Worker
1119*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
1120*58b9f456SAndroid Build Coastguard Workerint
1121*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::sync()
1122*58b9f456SAndroid Build Coastguard Worker{
1123*58b9f456SAndroid Build Coastguard Worker    int __r = 0;
1124*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1125*58b9f456SAndroid Build Coastguard Worker    try
1126*58b9f456SAndroid Build Coastguard Worker    {
1127*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1128*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
1129*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1130*58b9f456SAndroid Build Coastguard Worker        {
1131*58b9f456SAndroid Build Coastguard Worker            if (this->rdbuf() == 0)
1132*58b9f456SAndroid Build Coastguard Worker                return -1;
1133*58b9f456SAndroid Build Coastguard Worker            if (this->rdbuf()->pubsync() == -1)
1134*58b9f456SAndroid Build Coastguard Worker            {
1135*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::badbit);
1136*58b9f456SAndroid Build Coastguard Worker                return -1;
1137*58b9f456SAndroid Build Coastguard Worker            }
1138*58b9f456SAndroid Build Coastguard Worker        }
1139*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1140*58b9f456SAndroid Build Coastguard Worker    }
1141*58b9f456SAndroid Build Coastguard Worker    catch (...)
1142*58b9f456SAndroid Build Coastguard Worker    {
1143*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
1144*58b9f456SAndroid Build Coastguard Worker    }
1145*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1146*58b9f456SAndroid Build Coastguard Worker    return __r;
1147*58b9f456SAndroid Build Coastguard Worker}
1148*58b9f456SAndroid Build Coastguard Worker
1149*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
1150*58b9f456SAndroid Build Coastguard Workertypename basic_istream<_CharT, _Traits>::pos_type
1151*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::tellg()
1152*58b9f456SAndroid Build Coastguard Worker{
1153*58b9f456SAndroid Build Coastguard Worker    pos_type __r(-1);
1154*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1155*58b9f456SAndroid Build Coastguard Worker    try
1156*58b9f456SAndroid Build Coastguard Worker    {
1157*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1158*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
1159*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1160*58b9f456SAndroid Build Coastguard Worker            __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
1161*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1162*58b9f456SAndroid Build Coastguard Worker    }
1163*58b9f456SAndroid Build Coastguard Worker    catch (...)
1164*58b9f456SAndroid Build Coastguard Worker    {
1165*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
1166*58b9f456SAndroid Build Coastguard Worker    }
1167*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1168*58b9f456SAndroid Build Coastguard Worker    return __r;
1169*58b9f456SAndroid Build Coastguard Worker}
1170*58b9f456SAndroid Build Coastguard Worker
1171*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
1172*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1173*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::seekg(pos_type __pos)
1174*58b9f456SAndroid Build Coastguard Worker{
1175*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1176*58b9f456SAndroid Build Coastguard Worker    try
1177*58b9f456SAndroid Build Coastguard Worker    {
1178*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1179*58b9f456SAndroid Build Coastguard Worker        this->clear(this->rdstate() & ~ios_base::eofbit);
1180*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
1181*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1182*58b9f456SAndroid Build Coastguard Worker        {
1183*58b9f456SAndroid Build Coastguard Worker            if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
1184*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::failbit);
1185*58b9f456SAndroid Build Coastguard Worker        }
1186*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1187*58b9f456SAndroid Build Coastguard Worker    }
1188*58b9f456SAndroid Build Coastguard Worker    catch (...)
1189*58b9f456SAndroid Build Coastguard Worker    {
1190*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
1191*58b9f456SAndroid Build Coastguard Worker    }
1192*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1193*58b9f456SAndroid Build Coastguard Worker    return *this;
1194*58b9f456SAndroid Build Coastguard Worker}
1195*58b9f456SAndroid Build Coastguard Worker
1196*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits>
1197*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1198*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
1199*58b9f456SAndroid Build Coastguard Worker{
1200*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1201*58b9f456SAndroid Build Coastguard Worker    try
1202*58b9f456SAndroid Build Coastguard Worker    {
1203*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1204*58b9f456SAndroid Build Coastguard Worker        this->clear(this->rdstate() & ~ios_base::eofbit);
1205*58b9f456SAndroid Build Coastguard Worker        sentry __sen(*this, true);
1206*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1207*58b9f456SAndroid Build Coastguard Worker        {
1208*58b9f456SAndroid Build Coastguard Worker            if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
1209*58b9f456SAndroid Build Coastguard Worker                this->setstate(ios_base::failbit);
1210*58b9f456SAndroid Build Coastguard Worker        }
1211*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1212*58b9f456SAndroid Build Coastguard Worker    }
1213*58b9f456SAndroid Build Coastguard Worker    catch (...)
1214*58b9f456SAndroid Build Coastguard Worker    {
1215*58b9f456SAndroid Build Coastguard Worker        this->__set_badbit_and_consider_rethrow();
1216*58b9f456SAndroid Build Coastguard Worker    }
1217*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1218*58b9f456SAndroid Build Coastguard Worker    return *this;
1219*58b9f456SAndroid Build Coastguard Worker}
1220*58b9f456SAndroid Build Coastguard Worker
1221*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1222*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1223*58b9f456SAndroid Build Coastguard Workerws(basic_istream<_CharT, _Traits>& __is)
1224*58b9f456SAndroid Build Coastguard Worker{
1225*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1226*58b9f456SAndroid Build Coastguard Worker    try
1227*58b9f456SAndroid Build Coastguard Worker    {
1228*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1229*58b9f456SAndroid Build Coastguard Worker        typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1230*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1231*58b9f456SAndroid Build Coastguard Worker        {
1232*58b9f456SAndroid Build Coastguard Worker            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1233*58b9f456SAndroid Build Coastguard Worker            while (true)
1234*58b9f456SAndroid Build Coastguard Worker            {
1235*58b9f456SAndroid Build Coastguard Worker                typename _Traits::int_type __i = __is.rdbuf()->sgetc();
1236*58b9f456SAndroid Build Coastguard Worker                if (_Traits::eq_int_type(__i, _Traits::eof()))
1237*58b9f456SAndroid Build Coastguard Worker                {
1238*58b9f456SAndroid Build Coastguard Worker                   __is.setstate(ios_base::eofbit);
1239*58b9f456SAndroid Build Coastguard Worker                   break;
1240*58b9f456SAndroid Build Coastguard Worker                }
1241*58b9f456SAndroid Build Coastguard Worker                if (!__ct.is(__ct.space, _Traits::to_char_type(__i)))
1242*58b9f456SAndroid Build Coastguard Worker                    break;
1243*58b9f456SAndroid Build Coastguard Worker                __is.rdbuf()->sbumpc();
1244*58b9f456SAndroid Build Coastguard Worker            }
1245*58b9f456SAndroid Build Coastguard Worker        }
1246*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1247*58b9f456SAndroid Build Coastguard Worker    }
1248*58b9f456SAndroid Build Coastguard Worker    catch (...)
1249*58b9f456SAndroid Build Coastguard Worker    {
1250*58b9f456SAndroid Build Coastguard Worker        __is.__set_badbit_and_consider_rethrow();
1251*58b9f456SAndroid Build Coastguard Worker    }
1252*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1253*58b9f456SAndroid Build Coastguard Worker    return __is;
1254*58b9f456SAndroid Build Coastguard Worker}
1255*58b9f456SAndroid Build Coastguard Worker
1256*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1257*58b9f456SAndroid Build Coastguard Worker
1258*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Tp>
1259*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1260*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1261*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x)
1262*58b9f456SAndroid Build Coastguard Worker{
1263*58b9f456SAndroid Build Coastguard Worker    __is >> _VSTD::forward<_Tp>(__x);
1264*58b9f456SAndroid Build Coastguard Worker    return __is;
1265*58b9f456SAndroid Build Coastguard Worker}
1266*58b9f456SAndroid Build Coastguard Worker
1267*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1268*58b9f456SAndroid Build Coastguard Worker
1269*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1270*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_iostream
1271*58b9f456SAndroid Build Coastguard Worker    : public basic_istream<_CharT, _Traits>,
1272*58b9f456SAndroid Build Coastguard Worker      public basic_ostream<_CharT, _Traits>
1273*58b9f456SAndroid Build Coastguard Worker{
1274*58b9f456SAndroid Build Coastguard Workerpublic:
1275*58b9f456SAndroid Build Coastguard Worker    // types:
1276*58b9f456SAndroid Build Coastguard Worker    typedef _CharT                         char_type;
1277*58b9f456SAndroid Build Coastguard Worker    typedef _Traits                        traits_type;
1278*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::int_type int_type;
1279*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::pos_type pos_type;
1280*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::off_type off_type;
1281*58b9f456SAndroid Build Coastguard Worker
1282*58b9f456SAndroid Build Coastguard Worker    // constructor/destructor
1283*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
1284*58b9f456SAndroid Build Coastguard Worker    explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
1285*58b9f456SAndroid Build Coastguard Worker      : basic_istream<_CharT, _Traits>(__sb)
1286*58b9f456SAndroid Build Coastguard Worker    {}
1287*58b9f456SAndroid Build Coastguard Worker
1288*58b9f456SAndroid Build Coastguard Worker    virtual ~basic_iostream();
1289*58b9f456SAndroid Build Coastguard Workerprotected:
1290*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1291*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
1292*58b9f456SAndroid Build Coastguard Worker    basic_iostream(basic_iostream&& __rhs);
1293*58b9f456SAndroid Build Coastguard Worker
1294*58b9f456SAndroid Build Coastguard Worker    // assign/swap
1295*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
1296*58b9f456SAndroid Build Coastguard Worker    basic_iostream& operator=(basic_iostream&& __rhs);
1297*58b9f456SAndroid Build Coastguard Worker#endif
1298*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
1299*58b9f456SAndroid Build Coastguard Worker    void swap(basic_iostream& __rhs)
1300*58b9f456SAndroid Build Coastguard Worker    { basic_istream<char_type, traits_type>::swap(__rhs); }
1301*58b9f456SAndroid Build Coastguard Workerpublic:
1302*58b9f456SAndroid Build Coastguard Worker};
1303*58b9f456SAndroid Build Coastguard Worker
1304*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1305*58b9f456SAndroid Build Coastguard Worker
1306*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1307*58b9f456SAndroid Build Coastguard Workerbasic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
1308*58b9f456SAndroid Build Coastguard Worker    : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
1309*58b9f456SAndroid Build Coastguard Worker{
1310*58b9f456SAndroid Build Coastguard Worker}
1311*58b9f456SAndroid Build Coastguard Worker
1312*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1313*58b9f456SAndroid Build Coastguard Workerbasic_iostream<_CharT, _Traits>&
1314*58b9f456SAndroid Build Coastguard Workerbasic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
1315*58b9f456SAndroid Build Coastguard Worker{
1316*58b9f456SAndroid Build Coastguard Worker    swap(__rhs);
1317*58b9f456SAndroid Build Coastguard Worker    return *this;
1318*58b9f456SAndroid Build Coastguard Worker}
1319*58b9f456SAndroid Build Coastguard Worker
1320*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1321*58b9f456SAndroid Build Coastguard Worker
1322*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits>
1323*58b9f456SAndroid Build Coastguard Workerbasic_iostream<_CharT, _Traits>::~basic_iostream()
1324*58b9f456SAndroid Build Coastguard Worker{
1325*58b9f456SAndroid Build Coastguard Worker}
1326*58b9f456SAndroid Build Coastguard Worker
1327*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
1328*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1329*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<_CharT, _Traits>& __is,
1330*58b9f456SAndroid Build Coastguard Worker           basic_string<_CharT, _Traits, _Allocator>& __str)
1331*58b9f456SAndroid Build Coastguard Worker{
1332*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1333*58b9f456SAndroid Build Coastguard Worker    try
1334*58b9f456SAndroid Build Coastguard Worker    {
1335*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1336*58b9f456SAndroid Build Coastguard Worker        typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
1337*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1338*58b9f456SAndroid Build Coastguard Worker        {
1339*58b9f456SAndroid Build Coastguard Worker            __str.clear();
1340*58b9f456SAndroid Build Coastguard Worker            streamsize __n = __is.width();
1341*58b9f456SAndroid Build Coastguard Worker            if (__n <= 0)
1342*58b9f456SAndroid Build Coastguard Worker                __n = __str.max_size();
1343*58b9f456SAndroid Build Coastguard Worker            if (__n <= 0)
1344*58b9f456SAndroid Build Coastguard Worker                __n = numeric_limits<streamsize>::max();
1345*58b9f456SAndroid Build Coastguard Worker            streamsize __c = 0;
1346*58b9f456SAndroid Build Coastguard Worker            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1347*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
1348*58b9f456SAndroid Build Coastguard Worker            while (__c < __n)
1349*58b9f456SAndroid Build Coastguard Worker            {
1350*58b9f456SAndroid Build Coastguard Worker                typename _Traits::int_type __i = __is.rdbuf()->sgetc();
1351*58b9f456SAndroid Build Coastguard Worker                if (_Traits::eq_int_type(__i, _Traits::eof()))
1352*58b9f456SAndroid Build Coastguard Worker                {
1353*58b9f456SAndroid Build Coastguard Worker                   __err |= ios_base::eofbit;
1354*58b9f456SAndroid Build Coastguard Worker                   break;
1355*58b9f456SAndroid Build Coastguard Worker                }
1356*58b9f456SAndroid Build Coastguard Worker                _CharT __ch = _Traits::to_char_type(__i);
1357*58b9f456SAndroid Build Coastguard Worker                if (__ct.is(__ct.space, __ch))
1358*58b9f456SAndroid Build Coastguard Worker                    break;
1359*58b9f456SAndroid Build Coastguard Worker                __str.push_back(__ch);
1360*58b9f456SAndroid Build Coastguard Worker                ++__c;
1361*58b9f456SAndroid Build Coastguard Worker                 __is.rdbuf()->sbumpc();
1362*58b9f456SAndroid Build Coastguard Worker            }
1363*58b9f456SAndroid Build Coastguard Worker            __is.width(0);
1364*58b9f456SAndroid Build Coastguard Worker            if (__c == 0)
1365*58b9f456SAndroid Build Coastguard Worker               __err |= ios_base::failbit;
1366*58b9f456SAndroid Build Coastguard Worker            __is.setstate(__err);
1367*58b9f456SAndroid Build Coastguard Worker        }
1368*58b9f456SAndroid Build Coastguard Worker        else
1369*58b9f456SAndroid Build Coastguard Worker            __is.setstate(ios_base::failbit);
1370*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1371*58b9f456SAndroid Build Coastguard Worker    }
1372*58b9f456SAndroid Build Coastguard Worker    catch (...)
1373*58b9f456SAndroid Build Coastguard Worker    {
1374*58b9f456SAndroid Build Coastguard Worker        __is.__set_badbit_and_consider_rethrow();
1375*58b9f456SAndroid Build Coastguard Worker    }
1376*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1377*58b9f456SAndroid Build Coastguard Worker    return __is;
1378*58b9f456SAndroid Build Coastguard Worker}
1379*58b9f456SAndroid Build Coastguard Worker
1380*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
1381*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1382*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<_CharT, _Traits>& __is,
1383*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
1384*58b9f456SAndroid Build Coastguard Worker{
1385*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1386*58b9f456SAndroid Build Coastguard Worker    try
1387*58b9f456SAndroid Build Coastguard Worker    {
1388*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1389*58b9f456SAndroid Build Coastguard Worker        typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1390*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1391*58b9f456SAndroid Build Coastguard Worker        {
1392*58b9f456SAndroid Build Coastguard Worker            __str.clear();
1393*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
1394*58b9f456SAndroid Build Coastguard Worker            streamsize __extr = 0;
1395*58b9f456SAndroid Build Coastguard Worker            while (true)
1396*58b9f456SAndroid Build Coastguard Worker            {
1397*58b9f456SAndroid Build Coastguard Worker                typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
1398*58b9f456SAndroid Build Coastguard Worker                if (_Traits::eq_int_type(__i, _Traits::eof()))
1399*58b9f456SAndroid Build Coastguard Worker                {
1400*58b9f456SAndroid Build Coastguard Worker                   __err |= ios_base::eofbit;
1401*58b9f456SAndroid Build Coastguard Worker                   break;
1402*58b9f456SAndroid Build Coastguard Worker                }
1403*58b9f456SAndroid Build Coastguard Worker                ++__extr;
1404*58b9f456SAndroid Build Coastguard Worker                _CharT __ch = _Traits::to_char_type(__i);
1405*58b9f456SAndroid Build Coastguard Worker                if (_Traits::eq(__ch, __dlm))
1406*58b9f456SAndroid Build Coastguard Worker                    break;
1407*58b9f456SAndroid Build Coastguard Worker                __str.push_back(__ch);
1408*58b9f456SAndroid Build Coastguard Worker                if (__str.size() == __str.max_size())
1409*58b9f456SAndroid Build Coastguard Worker                {
1410*58b9f456SAndroid Build Coastguard Worker                    __err |= ios_base::failbit;
1411*58b9f456SAndroid Build Coastguard Worker                    break;
1412*58b9f456SAndroid Build Coastguard Worker                }
1413*58b9f456SAndroid Build Coastguard Worker            }
1414*58b9f456SAndroid Build Coastguard Worker            if (__extr == 0)
1415*58b9f456SAndroid Build Coastguard Worker               __err |= ios_base::failbit;
1416*58b9f456SAndroid Build Coastguard Worker            __is.setstate(__err);
1417*58b9f456SAndroid Build Coastguard Worker        }
1418*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1419*58b9f456SAndroid Build Coastguard Worker    }
1420*58b9f456SAndroid Build Coastguard Worker    catch (...)
1421*58b9f456SAndroid Build Coastguard Worker    {
1422*58b9f456SAndroid Build Coastguard Worker        __is.__set_badbit_and_consider_rethrow();
1423*58b9f456SAndroid Build Coastguard Worker    }
1424*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1425*58b9f456SAndroid Build Coastguard Worker    return __is;
1426*58b9f456SAndroid Build Coastguard Worker}
1427*58b9f456SAndroid Build Coastguard Worker
1428*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
1429*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1430*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1431*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<_CharT, _Traits>& __is,
1432*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>& __str)
1433*58b9f456SAndroid Build Coastguard Worker{
1434*58b9f456SAndroid Build Coastguard Worker    return getline(__is, __str, __is.widen('\n'));
1435*58b9f456SAndroid Build Coastguard Worker}
1436*58b9f456SAndroid Build Coastguard Worker
1437*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1438*58b9f456SAndroid Build Coastguard Worker
1439*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
1440*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1441*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1442*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<_CharT, _Traits>&& __is,
1443*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
1444*58b9f456SAndroid Build Coastguard Worker{
1445*58b9f456SAndroid Build Coastguard Worker    return getline(__is, __str, __dlm);
1446*58b9f456SAndroid Build Coastguard Worker}
1447*58b9f456SAndroid Build Coastguard Worker
1448*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
1449*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1450*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1451*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<_CharT, _Traits>&& __is,
1452*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>& __str)
1453*58b9f456SAndroid Build Coastguard Worker{
1454*58b9f456SAndroid Build Coastguard Worker    return getline(__is, __str, __is.widen('\n'));
1455*58b9f456SAndroid Build Coastguard Worker}
1456*58b9f456SAndroid Build Coastguard Worker
1457*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1458*58b9f456SAndroid Build Coastguard Worker
1459*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, size_t _Size>
1460*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
1461*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
1462*58b9f456SAndroid Build Coastguard Worker{
1463*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1464*58b9f456SAndroid Build Coastguard Worker    try
1465*58b9f456SAndroid Build Coastguard Worker    {
1466*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1467*58b9f456SAndroid Build Coastguard Worker        typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
1468*58b9f456SAndroid Build Coastguard Worker        if (__sen)
1469*58b9f456SAndroid Build Coastguard Worker        {
1470*58b9f456SAndroid Build Coastguard Worker            basic_string<_CharT, _Traits> __str;
1471*58b9f456SAndroid Build Coastguard Worker            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1472*58b9f456SAndroid Build Coastguard Worker            size_t __c = 0;
1473*58b9f456SAndroid Build Coastguard Worker            ios_base::iostate __err = ios_base::goodbit;
1474*58b9f456SAndroid Build Coastguard Worker            _CharT __zero = __ct.widen('0');
1475*58b9f456SAndroid Build Coastguard Worker            _CharT __one = __ct.widen('1');
1476*58b9f456SAndroid Build Coastguard Worker            while (__c < _Size)
1477*58b9f456SAndroid Build Coastguard Worker            {
1478*58b9f456SAndroid Build Coastguard Worker                typename _Traits::int_type __i = __is.rdbuf()->sgetc();
1479*58b9f456SAndroid Build Coastguard Worker                if (_Traits::eq_int_type(__i, _Traits::eof()))
1480*58b9f456SAndroid Build Coastguard Worker                {
1481*58b9f456SAndroid Build Coastguard Worker                   __err |= ios_base::eofbit;
1482*58b9f456SAndroid Build Coastguard Worker                   break;
1483*58b9f456SAndroid Build Coastguard Worker                }
1484*58b9f456SAndroid Build Coastguard Worker                _CharT __ch = _Traits::to_char_type(__i);
1485*58b9f456SAndroid Build Coastguard Worker                if (!_Traits::eq(__ch, __zero) && !_Traits::eq(__ch, __one))
1486*58b9f456SAndroid Build Coastguard Worker                    break;
1487*58b9f456SAndroid Build Coastguard Worker                __str.push_back(__ch);
1488*58b9f456SAndroid Build Coastguard Worker                ++__c;
1489*58b9f456SAndroid Build Coastguard Worker                 __is.rdbuf()->sbumpc();
1490*58b9f456SAndroid Build Coastguard Worker            }
1491*58b9f456SAndroid Build Coastguard Worker            __x = bitset<_Size>(__str);
1492*58b9f456SAndroid Build Coastguard Worker            if (__c == 0)
1493*58b9f456SAndroid Build Coastguard Worker               __err |= ios_base::failbit;
1494*58b9f456SAndroid Build Coastguard Worker            __is.setstate(__err);
1495*58b9f456SAndroid Build Coastguard Worker        }
1496*58b9f456SAndroid Build Coastguard Worker        else
1497*58b9f456SAndroid Build Coastguard Worker            __is.setstate(ios_base::failbit);
1498*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1499*58b9f456SAndroid Build Coastguard Worker    }
1500*58b9f456SAndroid Build Coastguard Worker    catch (...)
1501*58b9f456SAndroid Build Coastguard Worker    {
1502*58b9f456SAndroid Build Coastguard Worker        __is.__set_badbit_and_consider_rethrow();
1503*58b9f456SAndroid Build Coastguard Worker    }
1504*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1505*58b9f456SAndroid Build Coastguard Worker    return __is;
1506*58b9f456SAndroid Build Coastguard Worker}
1507*58b9f456SAndroid Build Coastguard Worker
1508*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
1509*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)
1510*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)
1511*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)
1512*58b9f456SAndroid Build Coastguard Worker#endif
1513*58b9f456SAndroid Build Coastguard Worker
1514*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
1515*58b9f456SAndroid Build Coastguard Worker
1516*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS
1517*58b9f456SAndroid Build Coastguard Worker
1518*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_ISTREAM
1519