comparison DEPENDENCIES/generic/include/boost/pending/iterator_tests.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
23 # include <assert.h> 23 # include <assert.h>
24 # include <boost/type_traits.hpp> 24 # include <boost/type_traits.hpp>
25 # include <boost/static_assert.hpp> 25 # include <boost/static_assert.hpp>
26 # include <boost/concept_archetype.hpp> // for detail::dummy_constructor 26 # include <boost/concept_archetype.hpp> // for detail::dummy_constructor
27 # include <boost/implicit_cast.hpp> 27 # include <boost/implicit_cast.hpp>
28 # include <boost/type_traits/broken_compiler_spec.hpp>
29 28
30 namespace boost { 29 namespace boost {
31 30
32 // use this for the value type 31 // use this for the value type
33 struct dummyT { 32 struct dummyT {
34 dummyT() { } 33 dummyT() { }
35 dummyT(detail::dummy_constructor) { } 34 dummyT(detail::dummy_constructor) { }
36 dummyT(int x) : m_x(x) { } 35 dummyT(int x) : m_x(x) { }
37 int foo() const { return m_x; } 36 int foo() const { return m_x; }
38 bool operator==(const dummyT& d) const { return m_x == d.m_x; } 37 bool operator==(const dummyT& d) const { return m_x == d.m_x; }
39 int m_x; 38 int m_x;
40 }; 39 };
41 40
42 } 41 }
43 42
44 BOOST_TT_BROKEN_COMPILER_SPEC(boost::dummyT)
45
46 namespace boost { 43 namespace boost {
44 namespace iterators {
47 45
48 // Tests whether type Iterator satisfies the requirements for a 46 // Tests whether type Iterator satisfies the requirements for a
49 // TrivialIterator. 47 // TrivialIterator.
50 // Preconditions: i != j, *i == val 48 // Preconditions: i != j, *i == val
51 template <class Iterator, class T> 49 template <class Iterator, class T>
52 void trivial_iterator_test(const Iterator i, const Iterator j, T val) 50 void trivial_iterator_test(const Iterator i, const Iterator j, T val)
53 { 51 {
54 Iterator k; 52 Iterator k;
85 } 83 }
86 84
87 85
88 // Preconditions: *i == v1, *++i == v2 86 // Preconditions: *i == v1, *++i == v2
89 template <class Iterator, class T> 87 template <class Iterator, class T>
90 void input_iterator_test(Iterator i, T v1, T v2) 88 void input_iterator_test(Iterator i, T v1, T v2)
91 { 89 {
92 Iterator i1(i); 90 Iterator i1(i);
93 91
94 assert(i == i1); 92 assert(i == i1);
95 assert(!(i != i1)); 93 assert(!(i != i1));
151 template <class T> static void check(T) {} 149 template <class T> static void check(T) {}
152 }; 150 };
153 #endif 151 #endif
154 152
155 template <class Iterator, class T> 153 template <class Iterator, class T>
156 void forward_iterator_test(Iterator i, T v1, T v2) 154 void forward_iterator_test(Iterator i, T v1, T v2)
157 { 155 {
158 input_iterator_test(i, v1, v2); 156 input_iterator_test(i, v1, v2);
159 157
160 Iterator i1 = i, i2 = i; 158 Iterator i1 = i, i2 = i;
161 159
216 bidirectional_iterator_test(i, vals[0], vals[1]); 214 bidirectional_iterator_test(i, vals[0], vals[1]);
217 const Iterator j = i; 215 const Iterator j = i;
218 int c; 216 int c;
219 217
220 typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type; 218 typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type;
221 219
222 for (c = 0; c < N-1; ++c) { 220 for (c = 0; c < N-1; ++c) {
223 assert(i == j + c); 221 assert(i == j + c);
224 assert(*i == vals[c]); 222 assert(*i == vals[c]);
225 assert(*i == boost::implicit_cast<value_type>(j[c])); 223 assert(*i == boost::implicit_cast<value_type>(j[c]));
226 assert(*i == *(j + c)); 224 assert(*i == *(j + c));
235 Iterator k = j + N - 1; 233 Iterator k = j + N - 1;
236 for (c = 0; c < N-1; ++c) { 234 for (c = 0; c < N-1; ++c) {
237 assert(i == k - c); 235 assert(i == k - c);
238 assert(*i == vals[N - 1 - c]); 236 assert(*i == vals[N - 1 - c]);
239 assert(*i == boost::implicit_cast<value_type>(j[N - 1 - c])); 237 assert(*i == boost::implicit_cast<value_type>(j[N - 1 - c]));
240 Iterator q = k - c; 238 Iterator q = k - c;
241 assert(*i == *q); 239 assert(*i == *q);
242 assert(i > j); 240 assert(i > j);
243 assert(i >= j); 241 assert(i >= j);
244 assert(j <= i); 242 assert(j <= i);
245 assert(j < i); 243 assert(j < i);
261 k = i; 259 k = i;
262 assert(k == i); 260 assert(k == i);
263 assert(i == k); 261 assert(i == k);
264 } 262 }
265 263
264 } // namespace iterators
265
266 using iterators::undefined;
267 using iterators::trivial_iterator_test;
268 using iterators::mutable_trivial_iterator_test;
269 using iterators::input_iterator_test;
270 using iterators::lvalue_test;
271 using iterators::forward_iterator_test;
272 using iterators::bidirectional_iterator_test;
273 using iterators::random_access_iterator_test;
274 using iterators::const_nonconst_iterator_test;
275
266 } // namespace boost 276 } // namespace boost
267 277
268 #endif // BOOST_ITERATOR_TESTS_HPP 278 #endif // BOOST_ITERATOR_TESTS_HPP