1
1
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
2
3
+ #include < iterator>
3
4
#if !defined(CPPLINQ_LINQ_ITERATORS_HPP)
4
5
#define CPPLINQ_LINQ_ITERATORS_HPP
5
6
#pragma once
@@ -71,8 +72,8 @@ namespace cpplinq {
71
72
>::type
72
73
operator >=(const Iter& it, const Iter& it2) {
73
74
return !(it < it2);
74
- }
75
-
75
+ }
76
+
76
77
namespace util {
77
78
template <class Iter , class T >
78
79
typename std::iterator_traits<Iter>::pointer deref_iterator (const Iter& it) {
@@ -88,9 +89,9 @@ namespace cpplinq {
88
89
util::value_ptr<T> deref_iterator (const Iter& it, util::identity<T>) {
89
90
return util::value_ptr<T>(*it);
90
91
}
91
- }
92
-
93
-
92
+ }
93
+
94
+
94
95
template <class Iter >
95
96
class iter_range
96
97
{
@@ -113,16 +114,20 @@ namespace cpplinq {
113
114
114
115
// decays into a onepass/forward iterator
115
116
template <class Cursor >
116
- class cursor_iterator
117
- : public std::iterator<std::forward_iterator_tag,
118
- typename Cursor::element_type,
119
- std::ptrdiff_t ,
120
- typename std::conditional<std::is_reference<typename Cursor::reference_type>::value,
121
- typename std::add_pointer<typename Cursor::element_type>::type,
122
- util::value_ptr<typename Cursor::element_type>>::type,
123
- typename Cursor::reference_type>
117
+ class cursor_iterator
124
118
{
125
119
public:
120
+ using iterator_category = std::forward_iterator_tag;
121
+ using value_type = typename Cursor::element_type;
122
+ using difference_type = std::ptrdiff_t ;
123
+ using pointer =
124
+ typename std::conditional<
125
+ std::is_reference<typename Cursor::reference_type>::value,
126
+ typename std::add_pointer<typename Cursor::element_type>::type,
127
+ util::value_ptr<typename Cursor::element_type>
128
+ >::type;
129
+ using reference = typename Cursor::reference_type;
130
+
126
131
CPPLINQ_USE_DEFAULT_ITERATOR_OPERATORS;
127
132
128
133
cursor_iterator (Cursor cur) : cur(cur) {
@@ -143,7 +148,7 @@ namespace cpplinq {
143
148
auto & v = **this ;
144
149
return &v;
145
150
}
146
-
151
+
147
152
cursor_iterator& operator ++() {
148
153
cur->inc ();
149
154
@@ -159,7 +164,7 @@ namespace cpplinq {
159
164
}
160
165
161
166
162
-
167
+
163
168
private:
164
169
bool empty () const {
165
170
return !cur || cur->empty ();
@@ -176,7 +181,7 @@ namespace cpplinq {
176
181
public:
177
182
typedef cursor_iterator<typename Container::cursor> iterator;
178
183
179
- container_range (Container c) : c(c)
184
+ container_range (Container c) : c(c)
180
185
{
181
186
}
182
187
0 commit comments