30 #ifndef _STREAM_ITERATOR_H
31 #define _STREAM_ITERATOR_H 1
33 #pragma GCC system_header
37 _GLIBCXX_BEGIN_NAMESPACE(
std)
40 template<typename _Tp, typename _CharT =
char,
41 typename _Traits = char_traits<_CharT>, typename _Dist = ptrdiff_t>
46 typedef _CharT char_type;
47 typedef _Traits traits_type;
48 typedef basic_istream<_CharT, _Traits> istream_type;
51 istream_type* _M_stream;
58 : _M_stream(0), _M_value(), _M_ok(false) {}
66 : _M_stream(__obj._M_stream), _M_value(__obj._M_value),
73 __glibcxx_requires_cond(_M_ok,
74 _M_message(__gnu_debug::__msg_deref_istream)
80 operator->()
const {
return &(operator*()); }
85 __glibcxx_requires_cond(_M_ok,
86 _M_message(__gnu_debug::__msg_inc_istream)
95 __glibcxx_requires_cond(_M_ok,
96 _M_message(__gnu_debug::__msg_inc_istream)
98 istream_iterator __tmp = *
this;
104 _M_equal(
const istream_iterator& __x)
const
105 {
return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); }
111 _M_ok = (_M_stream && *_M_stream) ?
true :
false;
114 *_M_stream >> _M_value;
115 _M_ok = *_M_stream ?
true :
false;
121 template<
typename _Tp,
typename _CharT,
typename _Traits,
typename _Dist>
125 {
return __x._M_equal(__y); }
128 template <
class _Tp,
class _CharT,
class _Traits,
class _Dist>
132 {
return !__x._M_equal(__y); }
145 template<
typename _Tp,
typename _CharT = char,
146 typename _Traits = char_traits<_CharT> >
148 :
public iterator<output_iterator_tag, void, void, void, void>
159 ostream_type* _M_stream;
160 const _CharT* _M_string;
177 : _M_stream(&__s), _M_string(__c) { }
181 : _M_stream(__obj._M_stream), _M_string(__obj._M_string) { }
188 __glibcxx_requires_cond(_M_stream != 0,
189 _M_message(__gnu_debug::__msg_output_ostream)
190 ._M_iterator(*
this));
191 *_M_stream << __value;
192 if (_M_string) *_M_stream << _M_string;
209 _GLIBCXX_END_NAMESPACE
bool operator==(const istream_iterator< _Tp, _CharT, _Traits, _Dist > &__x, const istream_iterator< _Tp, _CharT, _Traits, _Dist > &__y)
Return true if x and y are both end or not end, or x and y are the same.
basic_ostream< _CharT, _Traits > ostream_type
Public typedef.
ISO C++ entities toplevel namespace is std.
_CharT char_type
Public typedef.
ostream_iterator(ostream_type &__s)
Construct from an ostream.
Provides output iterator semantics for streams.
ostream_iterator(ostream_type &__s, const _CharT *__c)
_Traits traits_type
Public typedef.
istream_iterator(istream_type &__s)
Construct start of input stream iterator.
ostream_iterator & operator=(const _Tp &__value)
Writes value to underlying ostream using operator<<. If constructed with delimiter string...
bool operator!=(const istream_iterator< _Tp, _CharT, _Traits, _Dist > &__x, const istream_iterator< _Tp, _CharT, _Traits, _Dist > &__y)
Return false if x and y are both end or not end, or x and y are the same.
istream_iterator()
Construct end of input stream iterator.
Provides input iterator semantics for streams.
ostream_iterator(const ostream_iterator &__obj)
Copy constructor.