1717#define CPPREFERENCE_ITERATOR_H
1818
1919#include <cstddef> // for size_t, ptrdiff_t
20+ #include <iosfwd> // char_traits
21+ #include <initializer_list>
2022
2123namespace std {
2224
@@ -146,11 +148,14 @@ class move_iterator {
146148public:
147149 typedef Iterator iterator_type;
148150 typedef Iterator pointer;
149- typedef value_type&& reference;
150151#if CPPREFERENCE_SIMPLIFY_TYPEDEFS
152+ typedef typename Iterator::value_type value_type;
153+ typedef value_type&& reference;
151154 typedef typename ptrdiff_t difference_type;
152155 typedef typename Iterator::iterator_category iterator_category;
153156#else
157+ typedef typename iterator_traits<Iterator>::value_type value_type;
158+ typedef value_type&& reference;
154159 typedef typename iterator_traits<Iterator>::difference_type difference_type;
155160 typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
156161#endif
@@ -299,7 +304,7 @@ public:
299304 insert_iterator& operator++(int);
300305protected:
301306 Container* container;
302- Container::iterator iter;
307+ typename Container::iterator iter;
303308};
304309
305310template<class T,
@@ -331,11 +336,11 @@ public:
331336 istream_iterator operator++(int);
332337};
333338
334- template<class T, class CharT, class Traits, class Dist >
339+ template<class T, class CharT, class Traits, class Dist>
335340bool operator==(const istream_iterator<T, CharT, Traits, Dist>& lhs,
336341 const istream_iterator<T, CharT, Traits, Dist>& rhs);
337342
338- template<class CharT, class Traits >
343+ template<class T,class CharT, class Traits, class Dist >
339344bool operator!=(const istream_iterator<T, CharT, Traits, Dist>& lhs,
340345 const istream_iterator<T, CharT, Traits, Dist>& rhs);
341346
@@ -369,12 +374,12 @@ template<class T, class CharT, class Traits >
369374bool operator==(const ostream_iterator<T, CharT, Traits>& lhs,
370375 const ostream_iterator<T, CharT, Traits>& rhs);
371376
372- template<class CharT, class Traits >
377+ template<class T, class CharT, class Traits>
373378bool operator!=(const ostream_iterator<T, CharT, Traits>& lhs,
374379 const ostream_iterator<T, CharT, Traits>& rhs);
375380
376381
377- template<class CharT, class Traits = std::char_traits<CharT> >
382+ template<class CharT, class Traits /* = std::char_traits<CharT>*/ >
378383class istreambuf_iterator { // SIMPLIFIED: does not inherit iterator
379384public:
380385 typedef CharT char_type;
@@ -387,10 +392,10 @@ public:
387392 typedef std::basic_streambuf<CharT, Traits> streambuf_type;
388393 typedef std::basic_istream<CharT, Traits> istream_type;
389394
390- typedef T value_type;
391- typedef Distance difference_type;
392- typedef const T * pointer;
393- typedef const T & reference;
395+ typedef CharT value_type;
396+ typedef typename Traits::off_type difference_type;
397+ typedef const CharT * pointer; // actually unspecified
398+ typedef const CharT & reference;
394399 typedef input_iterator_tag iterator_category;
395400
396401 istreambuf_iterator();
@@ -417,7 +422,7 @@ bool operator!=(const istreambuf_iterator<CharT, Traits>& lhs,
417422 const istreambuf_iterator<CharT, Traits>& rhs);
418423
419424template<class CharT,
420- class Traits = std::char_traits<CharT> >
425+ class Traits /* = std::char_traits<CharT>*/ >
421426class ostreambuf_iterator { // SIMPLIFIED: does not inherit iterator
422427public:
423428 typedef CharT char_type;
0 commit comments