]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // (C) Copyright Jeremy Siek 2002. |
2 | // Distributed under the Boost Software License, Version 1.0. (See | |
3 | // accompanying file LICENSE_1_0.txt or copy at | |
4 | // http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #include <boost/iterator/iterator_concepts.hpp> | |
7 | #include <boost/iterator/iterator_categories.hpp> | |
8 | #include <boost/operators.hpp> | |
9 | ||
b32b8144 FG |
10 | #include <iterator> |
11 | #include <cstddef> | |
12 | ||
7c673cae FG |
13 | struct new_random_access |
14 | : std::random_access_iterator_tag | |
15 | , boost::random_access_traversal_tag | |
16 | {}; | |
17 | ||
18 | struct new_iterator | |
b32b8144 | 19 | : public std::iterator< new_random_access, int > |
7c673cae FG |
20 | { |
21 | int& operator*() const { return *m_x; } | |
22 | new_iterator& operator++() { return *this; } | |
23 | new_iterator operator++(int) { return *this; } | |
24 | new_iterator& operator--() { return *this; } | |
25 | new_iterator operator--(int) { return *this; } | |
26 | new_iterator& operator+=(std::ptrdiff_t) { return *this; } | |
27 | new_iterator operator+(std::ptrdiff_t) { return *this; } | |
28 | new_iterator& operator-=(std::ptrdiff_t) { return *this; } | |
29 | std::ptrdiff_t operator-(const new_iterator&) const { return 0; } | |
30 | new_iterator operator-(std::ptrdiff_t) const { return *this; } | |
31 | bool operator==(const new_iterator&) const { return false; } | |
32 | bool operator!=(const new_iterator&) const { return false; } | |
33 | bool operator<(const new_iterator&) const { return false; } | |
34 | int* m_x; | |
35 | }; | |
36 | new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; } | |
37 | ||
38 | struct old_iterator | |
b32b8144 | 39 | : public std::iterator<std::random_access_iterator_tag, int> |
7c673cae FG |
40 | { |
41 | int& operator*() const { return *m_x; } | |
42 | old_iterator& operator++() { return *this; } | |
43 | old_iterator operator++(int) { return *this; } | |
44 | old_iterator& operator--() { return *this; } | |
45 | old_iterator operator--(int) { return *this; } | |
46 | old_iterator& operator+=(std::ptrdiff_t) { return *this; } | |
47 | old_iterator operator+(std::ptrdiff_t) { return *this; } | |
48 | old_iterator& operator-=(std::ptrdiff_t) { return *this; } | |
49 | old_iterator operator-(std::ptrdiff_t) const { return *this; } | |
50 | std::ptrdiff_t operator-(const old_iterator&) const { return 0; } | |
51 | bool operator==(const old_iterator&) const { return false; } | |
52 | bool operator!=(const old_iterator&) const { return false; } | |
53 | bool operator<(const old_iterator&) const { return false; } | |
54 | int* m_x; | |
55 | }; | |
56 | old_iterator operator+(std::ptrdiff_t, old_iterator x) { return x; } | |
57 | ||
58 | int | |
59 | main() | |
60 | { | |
61 | boost::iterator_traversal<new_iterator>::type tc; | |
62 | boost::random_access_traversal_tag derived = tc; | |
63 | (void)derived; | |
64 | ||
65 | boost::function_requires< | |
66 | boost_concepts::WritableIteratorConcept<int*> >(); | |
67 | boost::function_requires< | |
68 | boost_concepts::LvalueIteratorConcept<int*> >(); | |
69 | boost::function_requires< | |
70 | boost_concepts::RandomAccessTraversalConcept<int*> >(); | |
71 | ||
72 | boost::function_requires< | |
73 | boost_concepts::ReadableIteratorConcept<const int*> >(); | |
74 | boost::function_requires< | |
75 | boost_concepts::LvalueIteratorConcept<const int*> >(); | |
76 | boost::function_requires< | |
77 | boost_concepts::RandomAccessTraversalConcept<const int*> >(); | |
78 | ||
79 | boost::function_requires< | |
80 | boost_concepts::WritableIteratorConcept<new_iterator> >(); | |
81 | boost::function_requires< | |
82 | boost_concepts::LvalueIteratorConcept<new_iterator> >(); | |
83 | boost::function_requires< | |
84 | boost_concepts::RandomAccessTraversalConcept<new_iterator> >(); | |
85 | ||
86 | boost::function_requires< | |
87 | boost_concepts::WritableIteratorConcept<old_iterator> >(); | |
88 | boost::function_requires< | |
89 | boost_concepts::LvalueIteratorConcept<old_iterator> >(); | |
90 | boost::function_requires< | |
91 | boost_concepts::RandomAccessTraversalConcept<old_iterator> >(); | |
92 | ||
93 | boost::function_requires< | |
94 | boost_concepts::InteroperableIteratorConcept<int*, int const*> >(); | |
95 | ||
96 | return 0; | |
97 | } |