5 #ifndef V8_BASE_ITERATOR_H_ 6 #define V8_BASE_ITERATOR_H_ 13 template <
class Category,
class Type,
class Diff = std::ptrdiff_t,
14 class Pointer =
Type*,
class Reference =
Type&>
16 typedef Category iterator_category;
18 typedef Diff difference_type;
19 typedef Pointer pointer;
20 typedef Reference reference;
27 template <
typename ForwardIterator>
30 typedef ForwardIterator iterator;
31 typedef ForwardIterator const_iterator;
32 typedef typename std::iterator_traits<iterator>::pointer pointer;
33 typedef typename std::iterator_traits<iterator>::reference reference;
34 typedef typename std::iterator_traits<iterator>::value_type value_type;
36 typename std::iterator_traits<iterator>::difference_type difference_type;
39 template <
typename ForwardIterator1,
typename ForwardIterator2>
41 : begin_(std::forward<ForwardIterator1>(begin)),
42 end_(std::forward<ForwardIterator2>(end)) {}
44 iterator begin() {
return begin_; }
45 iterator end() {
return end_; }
46 const_iterator begin()
const {
return begin_; }
47 const_iterator end()
const {
return end_; }
48 const_iterator cbegin()
const {
return begin_; }
49 const_iterator cend()
const {
return end_; }
51 bool empty()
const {
return cbegin() == cend(); }
54 reference operator[](difference_type n) {
return begin()[n]; }
55 difference_type size()
const {
return cend() - cbegin(); }
58 const_iterator
const begin_;
59 const_iterator
const end_;
65 #endif // V8_BASE_ITERATOR_H_