1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef INPUT_ITERATOR_H
11#define INPUT_ITERATOR_H
12
13#include <iterator>
14
15template <class It>
16class input_iterator
17{
18    It it_;
19public:
20    typedef typename std::input_iterator_tag                   iterator_category;
21    typedef typename std::iterator_traits<It>::value_type      value_type;
22    typedef typename std::iterator_traits<It>::difference_type difference_type;
23    typedef It                                                 pointer;
24    typedef typename std::iterator_traits<It>::reference       reference;
25
26    input_iterator() : it_() {}
27    explicit input_iterator(It it) : it_(it) {}
28
29    reference operator*() const {return *it_;}
30    pointer operator->() const {return it_;}
31
32    input_iterator& operator++() {++it_; return *this;}
33    input_iterator operator++(int) {input_iterator tmp(*this); ++(*this); return tmp;}
34
35    friend bool operator==(const input_iterator& x, const input_iterator& y)
36        {return x.it_ == y.it_;}
37    friend bool operator!=(const input_iterator& x, const input_iterator& y)
38        {return !(x == y);}
39};
40
41#endif  // INPUT_ITERATOR_H
42