1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_ITERATORS_CONCATENATE_ITERATOR_HPP
11 #define BOOST_GEOMETRY_ITERATORS_CONCATENATE_ITERATOR_HPP
14 #include <type_traits>
16 #include <boost/iterator/iterator_facade.hpp>
17 #include <boost/iterator/iterator_categories.hpp>
20 namespace boost { namespace geometry
30 typename Reference = Value&
32 class concatenate_iterator
33 : public boost::iterator_facade
35 concatenate_iterator<Iterator1, Iterator2, Value, Reference>,
37 boost::bidirectional_traversal_tag,
42 Iterator1 m_it1, m_end1;
43 Iterator2 m_begin2, m_it2;
46 typedef Iterator1 first_iterator_type;
47 typedef Iterator2 second_iterator_type;
49 // default constructor
50 concatenate_iterator() = default;
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)
59 concatenate_iterator(Iterator1 end1, Iterator2 begin2, Iterator2 end2)
60 : m_it1(end1), m_end1(end1), m_begin2(begin2), m_it2(end2)
68 typename OtherReference,
71 std::is_convertible<OtherIt1, Iterator1>::value
72 && std::is_convertible<OtherIt2, Iterator2>::value,
76 concatenate_iterator(concatenate_iterator
84 , m_end1(other.m_end1)
85 , m_begin2(other.m_begin2)
89 concatenate_iterator(concatenate_iterator const& other) = default;
91 concatenate_iterator& operator=(concatenate_iterator const& other) = default;
94 friend class boost::iterator_core_access;
96 template <typename It1, typename It2, typename V, typename R>
97 friend class concatenate_iterator;
99 inline Reference dereference() const
101 if ( m_it1 == m_end1 )
113 typename OtherReference
115 inline bool equal(concatenate_iterator
121 > const& other) const
123 return m_it1 == other.m_it1 && m_it2 == other.m_it2;
126 inline void increment()
128 if ( m_it1 == m_end1 )
138 inline void decrement()
140 if ( m_it2 == m_begin2 )
153 }} // namespace boost::geometry
155 #endif // BOOST_GEOMETRY_ITERATORS_CONCATENATE_ITERATOR_HPP