30 #ifndef _STREAM_ITERATOR_H
31 #define _STREAM_ITERATOR_H 1
33 #pragma GCC system_header
37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
47 template<
typename _Tp,
typename _CharT = char,
48 typename _Traits = char_traits<_CharT>,
typename _Dist = ptrdiff_t>
50 :
public iterator<input_iterator_tag, _Tp, _Dist, const _Tp*, const _Tp&>
53 typedef _CharT char_type;
54 typedef _Traits traits_type;
65 : _M_stream(0), _M_value(), _M_ok(false) {}
73 : _M_stream(__obj._M_stream), _M_value(__obj._M_value),
80 __glibcxx_requires_cond(_M_ok,
81 _M_message(__gnu_debug::__msg_deref_istream)
87 operator->()
const {
return &(operator*()); }
92 __glibcxx_requires_cond(_M_ok,
93 _M_message(__gnu_debug::__msg_inc_istream)
102 __glibcxx_requires_cond(_M_ok,
103 _M_message(__gnu_debug::__msg_inc_istream)
104 ._M_iterator(*
this));
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>
132 {
return __x._M_equal(__y); }
135 template <
class _Tp,
class _CharT,
class _Traits,
class _Dist>
139 {
return !__x._M_equal(__y); }
152 template<
typename _Tp,
typename _CharT = char,
153 typename _Traits = char_traits<_CharT> >
155 :
public iterator<output_iterator_tag, void, void, void, void>
167 const _CharT* _M_string;
184 : _M_stream(&__s), _M_string(__c) { }
188 : _M_stream(__obj._M_stream), _M_string(__obj._M_string) { }
195 __glibcxx_requires_cond(_M_stream != 0,
196 _M_message(__gnu_debug::__msg_output_ostream)
197 ._M_iterator(*
this));
198 *_M_stream << __value;
199 if (_M_string) *_M_stream << _M_string;
218 _GLIBCXX_END_NAMESPACE_VERSION
_CharT char_type
Public typedef.
Template class basic_istream.
constexpr istream_iterator()
Construct end of input stream iterator.
ostream_iterator(ostream_type &__s)
Construct from an ostream.
istream_iterator(istream_type &__s)
Construct start of input stream iterator.
Provides input iterator semantics for streams.
basic_ostream< _CharT, _Traits > ostream_type
Public typedef.
_Traits traits_type
Public typedef.
ostream_iterator & operator=(const _Tp &__value)
Writes value to underlying ostream using operator<<. If constructed with delimiter string...
ostream_iterator(const ostream_iterator &__obj)
Copy constructor.
Provides output iterator semantics for streams.
Template class basic_ostream.
ostream_iterator(ostream_type &__s, const _CharT *__c)