]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/views/closeable_view.hpp
ba5bbd3f89d59ebc9c456e0ef70c4e5ee5bdddfc
[ceph.git] / ceph / src / boost / boost / geometry / views / closeable_view.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
6
7 // This file was modified by Oracle on 2020.
8 // Modifications copyright (c) 2020 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10
11 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
12 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
13
14 // Use, modification and distribution is subject to the Boost Software License,
15 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt)
17
18 #ifndef BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
19 #define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
20
21 #include <boost/geometry/core/closure.hpp>
22 #include <boost/geometry/core/ring_type.hpp>
23 #include <boost/geometry/core/tag.hpp>
24 #include <boost/geometry/core/tags.hpp>
25 #include <boost/geometry/iterators/closing_iterator.hpp>
26
27 #include <boost/geometry/views/identity_view.hpp>
28
29 namespace boost { namespace geometry
30 {
31
32 // Silence warning C4512: assignment operator could not be generated
33 #if defined(_MSC_VER)
34 #pragma warning(push)
35 #pragma warning(disable : 4512)
36 #endif
37
38 #ifndef DOXYGEN_NO_DETAIL
39
40 namespace detail
41 {
42
43 template <typename Range>
44 struct closing_view
45 {
46 // Keep this explicit, important for nested views/ranges
47 explicit inline closing_view(Range& r)
48 : m_range(r)
49 {}
50
51 typedef closing_iterator<Range> iterator;
52 typedef closing_iterator<Range const> const_iterator;
53
54 inline const_iterator begin() const { return const_iterator(m_range); }
55 inline const_iterator end() const { return const_iterator(m_range, true); }
56
57 inline iterator begin() { return iterator(m_range); }
58 inline iterator end() { return iterator(m_range, true); }
59 private :
60 Range& m_range;
61 };
62
63 }
64
65 #endif // DOXYGEN_NO_DETAIL
66
67
68 /*!
69 \brief View on a range, either closing it or leaving it as it is
70 \details The closeable_view is used internally by the library to handle all rings,
71 either closed or open, the same way. The default method is closed, all
72 algorithms process rings as if they are closed. Therefore, if they are opened,
73 a view is created which closes them.
74 The closeable_view might be used by library users, but its main purpose is
75 internally.
76 \tparam Range Original range
77 \tparam Close Specifies if it the range is closed, if so, nothing will happen.
78 If it is open, it will iterate the first point after the last point.
79 \ingroup views
80 */
81 template <typename Range, closure_selector Close>
82 struct closeable_view {};
83
84
85 #ifndef DOXYGEN_NO_SPECIALIZATIONS
86
87 template <typename Range>
88 struct closeable_view<Range, closed>
89 {
90 typedef identity_view<Range> type;
91 };
92
93
94 template <typename Range>
95 struct closeable_view<Range, open>
96 {
97 typedef detail::closing_view<Range> type;
98 };
99
100 #endif // DOXYGEN_NO_SPECIALIZATIONS
101
102
103 #if defined(_MSC_VER)
104 #pragma warning(pop)
105 #endif
106
107 }} // namespace boost::geometry
108
109
110 #endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP