Skip to content

Commit c2b846c

Browse files
committed
Added a test for filter_iterator converting constructor.
1 parent 1a7996e commit c2b846c

File tree

1 file changed

+46
-40
lines changed

1 file changed

+46
-40
lines changed

test/filter_iterator_test.cpp

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,78 +36,78 @@ int main()
3636
// Concept checks
3737
// Adapting old-style iterators
3838
{
39-
typedef boost::filter_iterator<one_or_four, boost::input_iterator_archetype<dummyT> > Iter;
39+
using Iter = boost::filter_iterator<one_or_four, boost::input_iterator_archetype<dummyT> >;
4040
boost::function_requires< boost::InputIteratorConcept<Iter> >();
4141
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
4242
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
4343
}
4444
{
45-
typedef boost::filter_iterator<one_or_four, boost::input_output_iterator_archetype<dummyT> > Iter;
45+
using Iter = boost::filter_iterator<one_or_four, boost::input_output_iterator_archetype<dummyT> >;
4646
boost::function_requires< boost::InputIteratorConcept<Iter> >();
4747
boost::function_requires< boost::OutputIteratorConcept<Iter, dummyT> >();
4848
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
4949
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
5050
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
5151
}
5252
{
53-
typedef boost::filter_iterator<one_or_four, boost::forward_iterator_archetype<dummyT> > Iter;
53+
using Iter = boost::filter_iterator<one_or_four, boost::forward_iterator_archetype<dummyT> >;
5454
boost::function_requires< boost::ForwardIteratorConcept<Iter> >();
5555
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
5656
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
5757
}
5858
{
59-
typedef boost::filter_iterator<one_or_four, boost::mutable_forward_iterator_archetype<dummyT> > Iter;
59+
using Iter = boost::filter_iterator<one_or_four, boost::mutable_forward_iterator_archetype<dummyT> >;
6060
boost::function_requires< boost::Mutable_ForwardIteratorConcept<Iter> >();
6161
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
6262
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
6363
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
6464
}
6565
{
66-
typedef boost::filter_iterator<one_or_four, boost::bidirectional_iterator_archetype<dummyT> > Iter;
66+
using Iter = boost::filter_iterator<one_or_four, boost::bidirectional_iterator_archetype<dummyT> >;
6767
boost::function_requires< boost::BidirectionalIteratorConcept<Iter> >();
6868
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
6969
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
7070
}
7171
{
72-
typedef boost::filter_iterator<one_or_four, boost::mutable_bidirectional_iterator_archetype<dummyT> > Iter;
72+
using Iter = boost::filter_iterator<one_or_four, boost::mutable_bidirectional_iterator_archetype<dummyT> >;
7373
boost::function_requires< boost::Mutable_BidirectionalIteratorConcept<Iter> >();
7474
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
7575
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
7676
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
7777
}
7878
{
79-
typedef boost::filter_iterator<one_or_four, boost::random_access_iterator_archetype<dummyT> > Iter;
79+
using Iter = boost::filter_iterator<one_or_four, boost::random_access_iterator_archetype<dummyT> >;
8080
boost::function_requires< boost::BidirectionalIteratorConcept<Iter> >();
8181
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
8282
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
8383
}
8484
{
85-
typedef boost::filter_iterator<one_or_four, boost::mutable_random_access_iterator_archetype<dummyT> > Iter;
85+
using Iter = boost::filter_iterator<one_or_four, boost::mutable_random_access_iterator_archetype<dummyT> >;
8686
boost::function_requires< boost::Mutable_BidirectionalIteratorConcept<Iter> >();
8787
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
8888
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
8989
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
9090
}
9191
// Adapting new-style iterators
9292
{
93-
typedef boost::iterator_archetype<
93+
using BaseIter = boost::iterator_archetype<
9494
const dummyT
9595
, boost::iterator_archetypes::readable_iterator_t
9696
, boost::single_pass_traversal_tag
97-
> BaseIter;
98-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
97+
>;
98+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
9999
boost::function_requires< boost::InputIteratorConcept<Iter> >();
100100
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
101101
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
102102
}
103103
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
104104
{
105-
typedef boost::iterator_archetype<
105+
using BaseIter = boost::iterator_archetype<
106106
dummyT
107107
, boost::iterator_archetypes::readable_writable_iterator_t
108108
, boost::single_pass_traversal_tag
109-
> BaseIter;
110-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
109+
>;
110+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
111111

112112
boost::function_requires< boost::InputIteratorConcept<Iter> >();
113113
boost::function_requires< boost::OutputIteratorConcept<Iter, dummyT> >();
@@ -117,48 +117,48 @@ int main()
117117
}
118118
#endif
119119
{
120-
typedef boost::iterator_archetype<
120+
using BaseIter = boost::iterator_archetype<
121121
const dummyT
122122
, boost::iterator_archetypes::readable_iterator_t
123123
, boost::forward_traversal_tag
124-
> BaseIter;
125-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
124+
>;
125+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
126126
boost::function_requires< boost::InputIteratorConcept<Iter> >();
127127
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
128128
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
129129
}
130130

131131
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
132132
{
133-
typedef boost::iterator_archetype<
133+
using BaseIter = boost::iterator_archetype<
134134
dummyT
135135
, boost::iterator_archetypes::readable_writable_iterator_t
136136
, boost::forward_traversal_tag
137-
> BaseIter;
138-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
137+
>;
138+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
139139
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
140140
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
141141
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
142142
}
143143
{
144-
typedef boost::iterator_archetype<
144+
using BaseIter = boost::iterator_archetype<
145145
const dummyT
146146
, boost::iterator_archetypes::readable_lvalue_iterator_t
147147
, boost::forward_traversal_tag
148-
> BaseIter;
149-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
148+
>;
149+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
150150
boost::function_requires< boost::ForwardIteratorConcept<Iter> >();
151151
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
152152
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
153153
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
154154
}
155155
{
156-
typedef boost::iterator_archetype<
156+
using BaseIter = boost::iterator_archetype<
157157
dummyT
158158
, boost::iterator_archetypes::writable_lvalue_iterator_t
159159
, boost::forward_traversal_tag
160-
> BaseIter;
161-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
160+
>;
161+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
162162
boost::function_requires< boost::Mutable_ForwardIteratorConcept<Iter> >();
163163
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
164164
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
@@ -167,48 +167,48 @@ int main()
167167
#endif
168168

169169
{
170-
typedef boost::iterator_archetype<
170+
using BaseIter = boost::iterator_archetype<
171171
const dummyT
172172
, boost::iterator_archetypes::readable_iterator_t
173173
, boost::random_access_traversal_tag
174-
> BaseIter;
175-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
174+
>;
175+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
176176
boost::function_requires< boost::InputIteratorConcept<Iter> >();
177177
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
178178
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
179179
}
180180

181181
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
182182
{
183-
typedef boost::iterator_archetype<
183+
using BaseIter = boost::iterator_archetype<
184184
dummyT
185185
, boost::iterator_archetypes::readable_writable_iterator_t
186186
, boost::random_access_traversal_tag
187-
> BaseIter;
188-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
187+
>;
188+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
189189
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
190190
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
191191
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
192192
}
193193
{
194-
typedef boost::iterator_archetype<
194+
using BaseIter = boost::iterator_archetype<
195195
const dummyT
196196
, boost::iterator_archetypes::readable_lvalue_iterator_t
197197
, boost::random_access_traversal_tag
198-
> BaseIter;
199-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
198+
>;
199+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
200200
boost::function_requires< boost::BidirectionalIteratorConcept<Iter> >();
201201
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
202202
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
203203
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
204204
}
205205
{
206-
typedef boost::iterator_archetype<
206+
using BaseIter = boost::iterator_archetype<
207207
dummyT
208208
, boost::iterator_archetypes::writable_lvalue_iterator_t
209209
, boost::random_access_traversal_tag
210-
> BaseIter;
211-
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
210+
>;
211+
using Iter = boost::filter_iterator<one_or_four, BaseIter>;
212212
boost::function_requires< boost::Mutable_BidirectionalIteratorConcept<Iter> >();
213213
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
214214
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
@@ -222,7 +222,7 @@ int main()
222222
dummyT(3), dummyT(4), dummyT(5) };
223223
const int N = sizeof(array)/sizeof(dummyT);
224224

225-
typedef boost::filter_iterator<one_or_four, dummyT*> filter_iter;
225+
using filter_iter = boost::filter_iterator<one_or_four, dummyT*>;
226226

227227
boost::bidirectional_readable_iterator_test(
228228
filter_iter(one_or_four(), array, array+N)
@@ -235,7 +235,13 @@ int main()
235235
>::value,
236236
"Filter interator must have a random_access_traversal_tag.");
237237

238-
//# endif
238+
// Check that the iterator can be constructed from a different but compatible iterator
239+
{
240+
using const_filter_iter = boost::filter_iterator<one_or_four, const dummyT*>;
241+
filter_iter mutable_it(one_or_four(), array+0, array+N);
242+
const_filter_iter const_it(mutable_it);
243+
(void)const_it;
244+
}
239245

240246
// On compilers not supporting partial specialization, we can do more type
241247
// deduction with deque iterators than with pointers... unless the library

0 commit comments

Comments
 (0)