30 #ifndef _STREAM_ITERATOR_H
31 #define _STREAM_ITERATOR_H 1
33 #pragma GCC system_header
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
46 template<
typename _Tp,
typename _CharT = char,
48 typename _Traits = char_traits<_CharT>,
typename _Dist =
ptrdiff_t>
49 class istream_iterator
50 :
public iterator<input_iterator_tag, _Tp, _Dist, const _Tp*, const _Tp&>
53 typedef _CharT char_type;
54 typedef _Traits traits_type;
55 typedef basic_istream<_CharT, _Traits> istream_type;
58 istream_type* _M_stream;
64 _GLIBCXX_CONSTEXPR istream_iterator()
65 : _M_stream(0), _M_value(), _M_ok(
false) {}
68 istream_iterator(istream_type& __s)
72 istream_iterator(
const istream_iterator& __obj)
73 : _M_stream(__obj._M_stream), _M_value(__obj._M_value),
87 operator->()
const {
return &(operator*()); }
104 ._M_iterator(*
this));
105 istream_iterator __tmp = *
this;
111 _M_equal(
const istream_iterator& __x)
const
112 {
return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); }
118 _M_ok = (_M_stream && *_M_stream) ?
true :
false;
121 *_M_stream >> _M_value;
122 _M_ok = *_M_stream ?
true :
false;
128 template<
typename _Tp,
typename _CharT,
typename _Traits,
typename _Dist>
130 operator==(
const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
131 const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y)
132 {
return __x._M_equal(__y); }
135 template <
class _Tp,
class _CharT,
class _Traits,
class _Dist>
137 operator!=(
const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
138 const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y)
139 {
return !__x._M_equal(__y); }
152 template<
typename _Tp,
typename _CharT = char,
153 typename _Traits = char_traits<_CharT> >
154 class ostream_iterator
155 :
public iterator<output_iterator_tag, void, void, void, void>
159 typedef _CharT char_type;
161 typedef _Traits traits_type;
162 typedef basic_ostream<_CharT, _Traits> ostream_type;
166 ostream_type* _M_stream;
167 const _CharT* _M_string;
171 ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {}
183 ostream_iterator(ostream_type& __s,
const _CharT* __c)
184 : _M_stream(&__s), _M_string(__c) { }
187 ostream_iterator(
const ostream_iterator& __obj)
188 : _M_stream(__obj._M_stream), _M_string(__obj._M_string) { }
193 operator=(
const _Tp& __value)
197 ._M_iterator(*
this));
198 *_M_stream << __value;
199 if (_M_string) *_M_stream << _M_string;
218 _GLIBCXX_END_NAMESPACE_VERSION
bool operator==(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
#define false
Definition: stdbool.h:35
Definition: formatter.h:101
namespace std _GLIBCXX_VISIBILITY(default)
Definition: auto_ptr.h:36
bool operator!=(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
Definition: formatter.h:98
Definition: formatter.h:99
__PTRDIFF_TYPE__ ptrdiff_t
Definition: stddef.h:147
#define __glibcxx_requires_cond(_Cond, _Msg)
Definition: debug.h:64