Last change
on this file since 33 was
29,
checked in by landauf, 17 years ago
|
updated boost from 1_33_1 to 1_34_1
|
File size:
1.5 KB
|
Line | |
---|
1 | // Copyright David Abrahams 2004. Use, modification and distribution is |
---|
2 | // subject to the Boost Software License, Version 1.0. (See accompanying |
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
4 | |
---|
5 | #include <boost/iterator/iterator_adaptor.hpp> |
---|
6 | #include <boost/pending/iterator_tests.hpp> |
---|
7 | #include <boost/detail/lightweight_test.hpp> |
---|
8 | #include <cassert> |
---|
9 | |
---|
10 | struct mutable_it : boost::iterator_adaptor<mutable_it,int*> |
---|
11 | { |
---|
12 | typedef boost::iterator_adaptor<mutable_it,int*> super_t; |
---|
13 | |
---|
14 | mutable_it(); |
---|
15 | explicit mutable_it(int* p) : super_t(p) {} |
---|
16 | |
---|
17 | bool equal(mutable_it const& rhs) const |
---|
18 | { |
---|
19 | return this->base() == rhs.base(); |
---|
20 | } |
---|
21 | }; |
---|
22 | |
---|
23 | struct constant_it : boost::iterator_adaptor<constant_it,int const*> |
---|
24 | { |
---|
25 | typedef boost::iterator_adaptor<constant_it,int const*> super_t; |
---|
26 | |
---|
27 | constant_it(); |
---|
28 | explicit constant_it(int* p) : super_t(p) {} |
---|
29 | constant_it(mutable_it const& x) : super_t(x.base()) {} |
---|
30 | |
---|
31 | bool equal(constant_it const& rhs) const |
---|
32 | { |
---|
33 | return this->base() == rhs.base(); |
---|
34 | } |
---|
35 | }; |
---|
36 | |
---|
37 | int main() |
---|
38 | { |
---|
39 | int data[] = { 49, 77 }; |
---|
40 | |
---|
41 | mutable_it i(data); |
---|
42 | constant_it j(data + 1); |
---|
43 | BOOST_TEST(i < j); |
---|
44 | BOOST_TEST(j > i); |
---|
45 | BOOST_TEST(i <= j); |
---|
46 | BOOST_TEST(j >= i); |
---|
47 | BOOST_TEST(j - i == 1); |
---|
48 | BOOST_TEST(i - j == -1); |
---|
49 | |
---|
50 | constant_it k = i; |
---|
51 | |
---|
52 | BOOST_TEST(!(i < k)); |
---|
53 | BOOST_TEST(!(k > i)); |
---|
54 | BOOST_TEST(i <= k); |
---|
55 | BOOST_TEST(k >= i); |
---|
56 | BOOST_TEST(k - i == 0); |
---|
57 | BOOST_TEST(i - k == 0); |
---|
58 | |
---|
59 | return boost::report_errors(); |
---|
60 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.