annotate libcxx/include/istream @ 222:81f6424ef0e3 llvm-original

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