]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/iterators/concatenate_iterator.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / iterators / concatenate_iterator.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014-2021, Oracle and/or its affiliates.
4 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9
10 #ifndef BOOST_GEOMETRY_ITERATORS_CONCATENATE_ITERATOR_HPP
11 #define BOOST_GEOMETRY_ITERATORS_CONCATENATE_ITERATOR_HPP
12
13
14 #include <type_traits>
15
16 #include <boost/iterator/iterator_facade.hpp>
17 #include <boost/iterator/iterator_categories.hpp>
18
19
20 namespace boost { namespace geometry
21 {
22
23
24
25 template
26 <
27 typename Iterator1,
28 typename Iterator2,
29 typename Value,
30 typename Reference = Value&
31 >
32 class concatenate_iterator
33 : public boost::iterator_facade
34 <
35 concatenate_iterator<Iterator1, Iterator2, Value, Reference>,
36 Value,
37 boost::bidirectional_traversal_tag,
38 Reference
39 >
40 {
41 private:
42 Iterator1 m_it1, m_end1;
43 Iterator2 m_begin2, m_it2;
44
45 public:
46 typedef Iterator1 first_iterator_type;
47 typedef Iterator2 second_iterator_type;
48
49 // default constructor
50 concatenate_iterator() = default;
51
52 // for begin
53 concatenate_iterator(Iterator1 it1, Iterator1 end1,
54 Iterator2 begin2, Iterator2 it2)
55 : m_it1(it1), m_end1(end1), m_begin2(begin2), m_it2(it2)
56 {}
57
58 // for end
59 concatenate_iterator(Iterator1 end1, Iterator2 begin2, Iterator2 end2)
60 : m_it1(end1), m_end1(end1), m_begin2(begin2), m_it2(end2)
61 {}
62
63 template
64 <
65 typename OtherIt1,
66 typename OtherIt2,
67 typename OtherValue,
68 typename OtherReference,
69 std::enable_if_t
70 <
71 std::is_convertible<OtherIt1, Iterator1>::value
72 && std::is_convertible<OtherIt2, Iterator2>::value,
73 int
74 > = 0
75 >
76 concatenate_iterator(concatenate_iterator
77 <
78 OtherIt1,
79 OtherIt2,
80 OtherValue,
81 OtherReference
82 > const& other)
83 : m_it1(other.m_it1)
84 , m_end1(other.m_end1)
85 , m_begin2(other.m_begin2)
86 , m_it2(other.m_it2)
87 {}
88
89 concatenate_iterator(concatenate_iterator const& other) = default;
90
91 concatenate_iterator& operator=(concatenate_iterator const& other) = default;
92
93 private:
94 friend class boost::iterator_core_access;
95
96 template <typename It1, typename It2, typename V, typename R>
97 friend class concatenate_iterator;
98
99 inline Reference dereference() const
100 {
101 if ( m_it1 == m_end1 )
102 {
103 return *m_it2;
104 }
105 return *m_it1;
106 }
107
108 template
109 <
110 typename OtherIt1,
111 typename OtherIt2,
112 typename OtherValue,
113 typename OtherReference
114 >
115 inline bool equal(concatenate_iterator
116 <
117 OtherIt1,
118 OtherIt2,
119 OtherValue,
120 OtherReference
121 > const& other) const
122 {
123 return m_it1 == other.m_it1 && m_it2 == other.m_it2;
124 }
125
126 inline void increment()
127 {
128 if ( m_it1 == m_end1 )
129 {
130 ++m_it2;
131 }
132 else
133 {
134 ++m_it1;
135 }
136 }
137
138 inline void decrement()
139 {
140 if ( m_it2 == m_begin2 )
141 {
142 --m_it1;
143 }
144 else
145 {
146 --m_it2;
147 }
148 }
149 };
150
151
152
153 }} // namespace boost::geometry
154
155 #endif // BOOST_GEOMETRY_ITERATORS_CONCATENATE_ITERATOR_HPP