user.cfg.in: Tweaks.
[gcc.git] / libstdc++-v3 / include / std / istream
1 // Input streams -*- C++ -*-
2
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008, 2009
5 // Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17
18 // You should have received a copy of the GNU General Public License
19 // along with this library; see the file COPYING. If not, write to
20 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301, USA.
22
23 // As a special exception, you may use this file as part of a free software
24 // library without restriction. Specifically, if other files instantiate
25 // templates or use macros or inline functions from this file, or you compile
26 // this file and link it with other files to produce an executable, this
27 // file does not by itself cause the resulting executable to be covered by
28 // the GNU General Public License. This exception does not however
29 // invalidate any other reasons why the executable file might be covered by
30 // the GNU General Public License.
31
32 //
33 // ISO C++ 14882: 27.6.1 Input streams
34 //
35
36 /** @file istream
37 * This is a Standard C++ Library header.
38 */
39
40 #ifndef _GLIBCXX_ISTREAM
41 #define _GLIBCXX_ISTREAM 1
42
43 #pragma GCC system_header
44
45 #include <ios>
46 #include <ostream>
47
48 _GLIBCXX_BEGIN_NAMESPACE(std)
49
50 // [27.6.1.1] Template class basic_istream
51 /**
52 * @brief Controlling input.
53 * @ingroup io
54 *
55 * This is the base class for all input streams. It provides text
56 * formatting of all builtin types, and communicates with any class
57 * derived from basic_streambuf to do the actual input.
58 */
59 template<typename _CharT, typename _Traits>
60 class basic_istream : virtual public basic_ios<_CharT, _Traits>
61 {
62 public:
63 // Types (inherited from basic_ios (27.4.4)):
64 typedef _CharT char_type;
65 typedef typename _Traits::int_type int_type;
66 typedef typename _Traits::pos_type pos_type;
67 typedef typename _Traits::off_type off_type;
68 typedef _Traits traits_type;
69
70 // Non-standard Types:
71 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
72 typedef basic_ios<_CharT, _Traits> __ios_type;
73 typedef basic_istream<_CharT, _Traits> __istream_type;
74 typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
75 __num_get_type;
76 typedef ctype<_CharT> __ctype_type;
77
78 protected:
79 // Data Members:
80 /**
81 * The number of characters extracted in the previous unformatted
82 * function; see gcount().
83 */
84 streamsize _M_gcount;
85
86 public:
87 // [27.6.1.1.1] constructor/destructor
88 /**
89 * @brief Base constructor.
90 *
91 * This ctor is almost never called by the user directly, rather from
92 * derived classes' initialization lists, which pass a pointer to
93 * their own stream buffer.
94 */
95 explicit
96 basic_istream(__streambuf_type* __sb)
97 : _M_gcount(streamsize(0))
98 { this->init(__sb); }
99
100 /**
101 * @brief Base destructor.
102 *
103 * This does very little apart from providing a virtual base dtor.
104 */
105 virtual
106 ~basic_istream()
107 { _M_gcount = streamsize(0); }
108
109 // [27.6.1.1.2] prefix/suffix
110 class sentry;
111 friend class sentry;
112
113 // [27.6.1.2] formatted input
114 // [27.6.1.2.3] basic_istream::operator>>
115 //@{
116 /**
117 * @brief Interface for manipulators.
118 *
119 * Manipulators such as @c std::ws and @c std::dec use these
120 * functions in constructs like "std::cin >> std::ws". For more
121 * information, see the iomanip header.
122 */
123 __istream_type&
124 operator>>(__istream_type& (*__pf)(__istream_type&))
125 { return __pf(*this); }
126
127 __istream_type&
128 operator>>(__ios_type& (*__pf)(__ios_type&))
129 {
130 __pf(*this);
131 return *this;
132 }
133
134 __istream_type&
135 operator>>(ios_base& (*__pf)(ios_base&))
136 {
137 __pf(*this);
138 return *this;
139 }
140 //@}
141
142 // [27.6.1.2.2] arithmetic extractors
143 /**
144 * @name Arithmetic Extractors
145 *
146 * All the @c operator>> functions (aka <em>formatted input
147 * functions</em>) have some common behavior. Each starts by
148 * constructing a temporary object of type std::basic_istream::sentry
149 * with the second argument (noskipws) set to false. This has several
150 * effects, concluding with the setting of a status flag; see the
151 * sentry documentation for more.
152 *
153 * If the sentry status is good, the function tries to extract
154 * whatever data is appropriate for the type of the argument.
155 *
156 * If an exception is thrown during extraction, ios_base::badbit
157 * will be turned on in the stream's error state without causing an
158 * ios_base::failure to be thrown. The original exception will then
159 * be rethrown.
160 */
161 //@{
162 /**
163 * @brief Basic arithmetic extractors
164 * @param A variable of builtin type.
165 * @return @c *this if successful
166 *
167 * These functions use the stream's current locale (specifically, the
168 * @c num_get facet) to parse the input data.
169 */
170 __istream_type&
171 operator>>(bool& __n)
172 { return _M_extract(__n); }
173
174 __istream_type&
175 operator>>(short& __n);
176
177 __istream_type&
178 operator>>(unsigned short& __n)
179 { return _M_extract(__n); }
180
181 __istream_type&
182 operator>>(int& __n);
183
184 __istream_type&
185 operator>>(unsigned int& __n)
186 { return _M_extract(__n); }
187
188 __istream_type&
189 operator>>(long& __n)
190 { return _M_extract(__n); }
191
192 __istream_type&
193 operator>>(unsigned long& __n)
194 { return _M_extract(__n); }
195
196 #ifdef _GLIBCXX_USE_LONG_LONG
197 __istream_type&
198 operator>>(long long& __n)
199 { return _M_extract(__n); }
200
201 __istream_type&
202 operator>>(unsigned long long& __n)
203 { return _M_extract(__n); }
204 #endif
205
206 __istream_type&
207 operator>>(float& __f)
208 { return _M_extract(__f); }
209
210 __istream_type&
211 operator>>(double& __f)
212 { return _M_extract(__f); }
213
214 __istream_type&
215 operator>>(long double& __f)
216 { return _M_extract(__f); }
217
218 __istream_type&
219 operator>>(void*& __p)
220 { return _M_extract(__p); }
221
222 /**
223 * @brief Extracting into another streambuf.
224 * @param sb A pointer to a streambuf
225 *
226 * This function behaves like one of the basic arithmetic extractors,
227 * in that it also constructs a sentry object and has the same error
228 * handling behavior.
229 *
230 * If @a sb is NULL, the stream will set failbit in its error state.
231 *
232 * Characters are extracted from this stream and inserted into the
233 * @a sb streambuf until one of the following occurs:
234 *
235 * - the input stream reaches end-of-file,
236 * - insertion into the output buffer fails (in this case, the
237 * character that would have been inserted is not extracted), or
238 * - an exception occurs (and in this case is caught)
239 *
240 * If the function inserts no characters, failbit is set.
241 */
242 __istream_type&
243 operator>>(__streambuf_type* __sb);
244 //@}
245
246 // [27.6.1.3] unformatted input
247 /**
248 * @brief Character counting
249 * @return The number of characters extracted by the previous
250 * unformatted input function dispatched for this stream.
251 */
252 streamsize
253 gcount() const
254 { return _M_gcount; }
255
256 /**
257 * @name Unformatted Input Functions
258 *
259 * All the unformatted input functions have some common behavior.
260 * Each starts by constructing a temporary object of type
261 * std::basic_istream::sentry with the second argument (noskipws)
262 * set to true. This has several effects, concluding with the
263 * setting of a status flag; see the sentry documentation for more.
264 *
265 * If the sentry status is good, the function tries to extract
266 * whatever data is appropriate for the type of the argument.
267 *
268 * The number of characters extracted is stored for later retrieval
269 * by gcount().
270 *
271 * If an exception is thrown during extraction, ios_base::badbit
272 * will be turned on in the stream's error state without causing an
273 * ios_base::failure to be thrown. The original exception will then
274 * be rethrown.
275 */
276 //@{
277 /**
278 * @brief Simple extraction.
279 * @return A character, or eof().
280 *
281 * Tries to extract a character. If none are available, sets failbit
282 * and returns traits::eof().
283 */
284 int_type
285 get();
286
287 /**
288 * @brief Simple extraction.
289 * @param c The character in which to store data.
290 * @return *this
291 *
292 * Tries to extract a character and store it in @a c. If none are
293 * available, sets failbit and returns traits::eof().
294 *
295 * @note This function is not overloaded on signed char and
296 * unsigned char.
297 */
298 __istream_type&
299 get(char_type& __c);
300
301 /**
302 * @brief Simple multiple-character extraction.
303 * @param s Pointer to an array.
304 * @param n Maximum number of characters to store in @a s.
305 * @param delim A "stop" character.
306 * @return *this
307 *
308 * Characters are extracted and stored into @a s until one of the
309 * following happens:
310 *
311 * - @c n-1 characters are stored
312 * - the input sequence reaches EOF
313 * - the next character equals @a delim, in which case the character
314 * is not extracted
315 *
316 * If no characters are stored, failbit is set in the stream's error
317 * state.
318 *
319 * In any case, a null character is stored into the next location in
320 * the array.
321 *
322 * @note This function is not overloaded on signed char and
323 * unsigned char.
324 */
325 __istream_type&
326 get(char_type* __s, streamsize __n, char_type __delim);
327
328 /**
329 * @brief Simple multiple-character extraction.
330 * @param s Pointer to an array.
331 * @param n Maximum number of characters to store in @a s.
332 * @return *this
333 *
334 * Returns @c get(s,n,widen('\n')).
335 */
336 __istream_type&
337 get(char_type* __s, streamsize __n)
338 { return this->get(__s, __n, this->widen('\n')); }
339
340 /**
341 * @brief Extraction into another streambuf.
342 * @param sb A streambuf in which to store data.
343 * @param delim A "stop" character.
344 * @return *this
345 *
346 * Characters are extracted and inserted into @a sb until one of the
347 * following happens:
348 *
349 * - the input sequence reaches EOF
350 * - insertion into the output buffer fails (in this case, the
351 * character that would have been inserted is not extracted)
352 * - the next character equals @a delim (in this case, the character
353 * is not extracted)
354 * - an exception occurs (and in this case is caught)
355 *
356 * If no characters are stored, failbit is set in the stream's error
357 * state.
358 */
359 __istream_type&
360 get(__streambuf_type& __sb, char_type __delim);
361
362 /**
363 * @brief Extraction into another streambuf.
364 * @param sb A streambuf in which to store data.
365 * @return *this
366 *
367 * Returns @c get(sb,widen('\n')).
368 */
369 __istream_type&
370 get(__streambuf_type& __sb)
371 { return this->get(__sb, this->widen('\n')); }
372
373 /**
374 * @brief String extraction.
375 * @param s A character array in which to store the data.
376 * @param n Maximum number of characters to extract.
377 * @param delim A "stop" character.
378 * @return *this
379 *
380 * Extracts and stores characters into @a s until one of the
381 * following happens. Note that these criteria are required to be
382 * tested in the order listed here, to allow an input line to exactly
383 * fill the @a s array without setting failbit.
384 *
385 * -# the input sequence reaches end-of-file, in which case eofbit
386 * is set in the stream error state
387 * -# the next character equals @c delim, in which case the character
388 * is extracted (and therefore counted in @c gcount()) but not stored
389 * -# @c n-1 characters are stored, in which case failbit is set
390 * in the stream error state
391 *
392 * If no characters are extracted, failbit is set. (An empty line of
393 * input should therefore not cause failbit to be set.)
394 *
395 * In any case, a null character is stored in the next location in
396 * the array.
397 */
398 __istream_type&
399 getline(char_type* __s, streamsize __n, char_type __delim);
400
401 /**
402 * @brief String extraction.
403 * @param s A character array in which to store the data.
404 * @param n Maximum number of characters to extract.
405 * @return *this
406 *
407 * Returns @c getline(s,n,widen('\n')).
408 */
409 __istream_type&
410 getline(char_type* __s, streamsize __n)
411 { return this->getline(__s, __n, this->widen('\n')); }
412
413 /**
414 * @brief Discarding characters
415 * @param n Number of characters to discard.
416 * @param delim A "stop" character.
417 * @return *this
418 *
419 * Extracts characters and throws them away until one of the
420 * following happens:
421 * - if @a n @c != @c std::numeric_limits<int>::max(), @a n
422 * characters are extracted
423 * - the input sequence reaches end-of-file
424 * - the next character equals @a delim (in this case, the character
425 * is extracted); note that this condition will never occur if
426 * @a delim equals @c traits::eof().
427 *
428 * NB: Provide three overloads, instead of the single function
429 * (with defaults) mandated by the Standard: this leads to a
430 * better performing implementation, while still conforming to
431 * the Standard.
432 */
433 __istream_type&
434 ignore();
435
436 __istream_type&
437 ignore(streamsize __n);
438
439 __istream_type&
440 ignore(streamsize __n, int_type __delim);
441
442 /**
443 * @brief Looking ahead in the stream
444 * @return The next character, or eof().
445 *
446 * If, after constructing the sentry object, @c good() is false,
447 * returns @c traits::eof(). Otherwise reads but does not extract
448 * the next input character.
449 */
450 int_type
451 peek();
452
453 /**
454 * @brief Extraction without delimiters.
455 * @param s A character array.
456 * @param n Maximum number of characters to store.
457 * @return *this
458 *
459 * If the stream state is @c good(), extracts characters and stores
460 * them into @a s until one of the following happens:
461 * - @a n characters are stored
462 * - the input sequence reaches end-of-file, in which case the error
463 * state is set to @c failbit|eofbit.
464 *
465 * @note This function is not overloaded on signed char and
466 * unsigned char.
467 */
468 __istream_type&
469 read(char_type* __s, streamsize __n);
470
471 /**
472 * @brief Extraction until the buffer is exhausted, but no more.
473 * @param s A character array.
474 * @param n Maximum number of characters to store.
475 * @return The number of characters extracted.
476 *
477 * Extracts characters and stores them into @a s depending on the
478 * number of characters remaining in the streambuf's buffer,
479 * @c rdbuf()->in_avail(), called @c A here:
480 * - if @c A @c == @c -1, sets eofbit and extracts no characters
481 * - if @c A @c == @c 0, extracts no characters
482 * - if @c A @c > @c 0, extracts @c min(A,n)
483 *
484 * The goal is to empty the current buffer, and to not request any
485 * more from the external input sequence controlled by the streambuf.
486 */
487 streamsize
488 readsome(char_type* __s, streamsize __n);
489
490 /**
491 * @brief Unextracting a single character.
492 * @param c The character to push back into the input stream.
493 * @return *this
494 *
495 * If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c).
496 *
497 * If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
498 * the error state.
499 *
500 * @note Since no characters are extracted, the next call to
501 * @c gcount() will return 0, as required by DR 60.
502 */
503 __istream_type&
504 putback(char_type __c);
505
506 /**
507 * @brief Unextracting the previous character.
508 * @return *this
509 *
510 * If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c).
511 *
512 * If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
513 * the error state.
514 *
515 * @note Since no characters are extracted, the next call to
516 * @c gcount() will return 0, as required by DR 60.
517 */
518 __istream_type&
519 unget();
520
521 /**
522 * @brief Synchronizing the stream buffer.
523 * @return 0 on success, -1 on failure
524 *
525 * If @c rdbuf() is a null pointer, returns -1.
526 *
527 * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
528 * sets badbit and returns -1.
529 *
530 * Otherwise, returns 0.
531 *
532 * @note This function does not count the number of characters
533 * extracted, if any, and therefore does not affect the next
534 * call to @c gcount().
535 */
536 int
537 sync();
538
539 /**
540 * @brief Getting the current read position.
541 * @return A file position object.
542 *
543 * If @c fail() is not false, returns @c pos_type(-1) to indicate
544 * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in).
545 *
546 * @note This function does not count the number of characters
547 * extracted, if any, and therefore does not affect the next
548 * call to @c gcount().
549 */
550 pos_type
551 tellg();
552
553 /**
554 * @brief Changing the current read position.
555 * @param pos A file position object.
556 * @return *this
557 *
558 * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If
559 * that function fails, sets failbit.
560 *
561 * @note This function does not count the number of characters
562 * extracted, if any, and therefore does not affect the next
563 * call to @c gcount().
564 */
565 __istream_type&
566 seekg(pos_type);
567
568 /**
569 * @brief Changing the current read position.
570 * @param off A file offset object.
571 * @param dir The direction in which to seek.
572 * @return *this
573 *
574 * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
575 * If that function fails, sets failbit.
576 *
577 * @note This function does not count the number of characters
578 * extracted, if any, and therefore does not affect the next
579 * call to @c gcount().
580 */
581 __istream_type&
582 seekg(off_type, ios_base::seekdir);
583 //@}
584
585 protected:
586 basic_istream()
587 : _M_gcount(streamsize(0))
588 { this->init(0); }
589
590 template<typename _ValueT>
591 __istream_type&
592 _M_extract(_ValueT& __v);
593 };
594
595 // Explicit specialization declarations, defined in src/istream.cc.
596 template<>
597 basic_istream<char>&
598 basic_istream<char>::
599 getline(char_type* __s, streamsize __n, char_type __delim);
600
601 template<>
602 basic_istream<char>&
603 basic_istream<char>::
604 ignore(streamsize __n);
605
606 template<>
607 basic_istream<char>&
608 basic_istream<char>::
609 ignore(streamsize __n, int_type __delim);
610
611 #ifdef _GLIBCXX_USE_WCHAR_T
612 template<>
613 basic_istream<wchar_t>&
614 basic_istream<wchar_t>::
615 getline(char_type* __s, streamsize __n, char_type __delim);
616
617 template<>
618 basic_istream<wchar_t>&
619 basic_istream<wchar_t>::
620 ignore(streamsize __n);
621
622 template<>
623 basic_istream<wchar_t>&
624 basic_istream<wchar_t>::
625 ignore(streamsize __n, int_type __delim);
626 #endif
627
628 /**
629 * @brief Performs setup work for input streams.
630 *
631 * Objects of this class are created before all of the standard
632 * extractors are run. It is responsible for "exception-safe prefix and
633 * suffix operations," although only prefix actions are currently required
634 * by the standard.
635 */
636 template<typename _CharT, typename _Traits>
637 class basic_istream<_CharT, _Traits>::sentry
638 {
639 public:
640 /// Easy access to dependant types.
641 typedef _Traits traits_type;
642 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
643 typedef basic_istream<_CharT, _Traits> __istream_type;
644 typedef typename __istream_type::__ctype_type __ctype_type;
645 typedef typename _Traits::int_type __int_type;
646
647 /**
648 * @brief The constructor performs all the work.
649 * @param is The input stream to guard.
650 * @param noskipws Whether to consume whitespace or not.
651 *
652 * If the stream state is good (@a is.good() is true), then the
653 * following actions are performed, otherwise the sentry state is
654 * false ("not okay") and failbit is set in the stream state.
655 *
656 * The sentry's preparatory actions are:
657 *
658 * -# if the stream is tied to an output stream, @c is.tie()->flush()
659 * is called to synchronize the output sequence
660 * -# if @a noskipws is false, and @c ios_base::skipws is set in
661 * @c is.flags(), the sentry extracts and discards whitespace
662 * characters from the stream. The currently imbued locale is
663 * used to determine whether each character is whitespace.
664 *
665 * If the stream state is still good, then the sentry state becomes
666 * true ("okay").
667 */
668 explicit
669 sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
670
671 /**
672 * @brief Quick status checking.
673 * @return The sentry state.
674 *
675 * For ease of use, sentries may be converted to booleans. The
676 * return value is that of the sentry state (true == okay).
677 */
678 operator bool() const
679 { return _M_ok; }
680
681 private:
682 bool _M_ok;
683 };
684
685 // [27.6.1.2.3] character extraction templates
686 //@{
687 /**
688 * @brief Character extractors
689 * @param in An input stream.
690 * @param c A character reference.
691 * @return in
692 *
693 * Behaves like one of the formatted arithmetic extractors described in
694 * std::basic_istream. After constructing a sentry object with good
695 * status, this function extracts a character (if one is available) and
696 * stores it in @a c. Otherwise, sets failbit in the input stream.
697 */
698 template<typename _CharT, typename _Traits>
699 basic_istream<_CharT, _Traits>&
700 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
701
702 template<class _Traits>
703 inline basic_istream<char, _Traits>&
704 operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
705 { return (__in >> reinterpret_cast<char&>(__c)); }
706
707 template<class _Traits>
708 inline basic_istream<char, _Traits>&
709 operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
710 { return (__in >> reinterpret_cast<char&>(__c)); }
711 //@}
712
713 //@{
714 /**
715 * @brief Character string extractors
716 * @param in An input stream.
717 * @param s A pointer to a character array.
718 * @return in
719 *
720 * Behaves like one of the formatted arithmetic extractors described in
721 * std::basic_istream. After constructing a sentry object with good
722 * status, this function extracts up to @c n characters and stores them
723 * into the array starting at @a s. @c n is defined as:
724 *
725 * - if @c width() is greater than zero, @c n is width()
726 * - otherwise @c n is "the number of elements of the largest array of
727 * @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6
728 *
729 * Characters are extracted and stored until one of the following happens:
730 * - @c n-1 characters are stored
731 * - EOF is reached
732 * - the next character is whitespace according to the current locale
733 * - the next character is a null byte (i.e., @c charT() )
734 *
735 * @c width(0) is then called for the input stream.
736 *
737 * If no characters are extracted, sets failbit.
738 */
739 template<typename _CharT, typename _Traits>
740 basic_istream<_CharT, _Traits>&
741 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
742
743 // Explicit specialization declaration, defined in src/istream.cc.
744 template<>
745 basic_istream<char>&
746 operator>>(basic_istream<char>& __in, char* __s);
747
748 template<class _Traits>
749 inline basic_istream<char, _Traits>&
750 operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
751 { return (__in >> reinterpret_cast<char*>(__s)); }
752
753 template<class _Traits>
754 inline basic_istream<char, _Traits>&
755 operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
756 { return (__in >> reinterpret_cast<char*>(__s)); }
757 //@}
758
759 // 27.6.1.5 Template class basic_iostream
760 /**
761 * @brief Merging istream and ostream capabilities.
762 * @ingroup io
763 *
764 * This class multiply inherits from the input and output stream classes
765 * simply to provide a single interface.
766 */
767 template<typename _CharT, typename _Traits>
768 class basic_iostream
769 : public basic_istream<_CharT, _Traits>,
770 public basic_ostream<_CharT, _Traits>
771 {
772 public:
773 // _GLIBCXX_RESOLVE_LIB_DEFECTS
774 // 271. basic_iostream missing typedefs
775 // Types (inherited):
776 typedef _CharT char_type;
777 typedef typename _Traits::int_type int_type;
778 typedef typename _Traits::pos_type pos_type;
779 typedef typename _Traits::off_type off_type;
780 typedef _Traits traits_type;
781
782 // Non-standard Types:
783 typedef basic_istream<_CharT, _Traits> __istream_type;
784 typedef basic_ostream<_CharT, _Traits> __ostream_type;
785
786 /**
787 * @brief Constructor does nothing.
788 *
789 * Both of the parent classes are initialized with the same
790 * streambuf pointer passed to this constructor.
791 */
792 explicit
793 basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
794 : __istream_type(__sb), __ostream_type(__sb) { }
795
796 /**
797 * @brief Destructor does nothing.
798 */
799 virtual
800 ~basic_iostream() { }
801
802 protected:
803 basic_iostream()
804 : __istream_type(), __ostream_type() { }
805 };
806
807 // [27.6.1.4] standard basic_istream manipulators
808 /**
809 * @brief Quick and easy way to eat whitespace
810 *
811 * This manipulator extracts whitespace characters, stopping when the
812 * next character is non-whitespace, or when the input sequence is empty.
813 * If the sequence is empty, @c eofbit is set in the stream, but not
814 * @c failbit.
815 *
816 * The current locale is used to distinguish whitespace characters.
817 *
818 * Example:
819 * @code
820 * MyClass mc;
821 *
822 * std::cin >> std::ws >> mc;
823 * @endcode
824 * will skip leading whitespace before calling operator>> on cin and your
825 * object. Note that the same effect can be achieved by creating a
826 * std::basic_istream::sentry inside your definition of operator>>.
827 */
828 template<typename _CharT, typename _Traits>
829 basic_istream<_CharT, _Traits>&
830 ws(basic_istream<_CharT, _Traits>& __is);
831
832 _GLIBCXX_END_NAMESPACE
833
834 #ifndef _GLIBCXX_EXPORT_TEMPLATE
835 # include <bits/istream.tcc>
836 #endif
837
838 #endif /* _GLIBCXX_ISTREAM */