]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/test_geometries/all_custom_container.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / test / test_geometries / all_custom_container.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10
11 #ifndef GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_CONTAINER_HPP
12 #define GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_CONTAINER_HPP
13
14 #include <cstddef>
15 #include <deque>
16
17
18 template <typename Item>
19 class all_custom_container
20 {
21 private :
22 std::deque<Item> m_hidden_deque;
23
24 public :
25 typedef typename std::deque<Item>::iterator custom_iterator_type;
26 typedef typename std::deque<Item>::const_iterator custom_const_iterator_type;
27
28 inline std::size_t custom_size() const { return m_hidden_deque.size(); }
29
30 inline custom_const_iterator_type custom_begin() const { return m_hidden_deque.begin(); }
31 inline custom_const_iterator_type custom_end() const { return m_hidden_deque.end(); }
32 inline custom_iterator_type custom_begin() { return m_hidden_deque.begin(); }
33 inline custom_iterator_type custom_end() { return m_hidden_deque.end(); }
34
35 inline void custom_clear() { m_hidden_deque.clear(); }
36 inline void custom_push_back(Item const& p) { m_hidden_deque.push_back(p); }
37 inline void custom_resize(std::size_t new_size) { m_hidden_deque.resize(new_size); }
38 };
39
40
41 // 1. Adapt to Boost.Geometry (for e.g. inner rings)
42 namespace boost { namespace geometry
43 {
44
45 namespace traits
46 {
47 template <typename Item>
48 struct clear<all_custom_container<Item> >
49 {
50 static inline void apply(all_custom_container<Item>& container)
51 {
52 container.custom_clear();
53 }
54 };
55
56 template <typename Item>
57 struct push_back<all_custom_container<Item> >
58 {
59 static inline void apply(all_custom_container<Item>& container, Item const& item)
60 {
61 container.custom_push_back(item);
62 }
63 };
64
65 template <typename Item>
66 struct resize<all_custom_container<Item> >
67 {
68 static inline void apply(all_custom_container<Item>& container, std::size_t new_size)
69 {
70 container.custom_resize(new_size);
71 }
72 };
73
74 } // namespace traits
75
76 }} // namespace boost::geometry
77
78
79 // 2a. Adapt to Boost.Range, meta-functions
80 namespace boost
81 {
82 template<typename Item>
83 struct range_mutable_iterator<all_custom_container<Item> >
84 {
85 typedef typename all_custom_container<Item>::custom_iterator_type type;
86 };
87
88 template<typename Item>
89 struct range_const_iterator<all_custom_container<Item> >
90 {
91 typedef typename all_custom_container<Item>::custom_const_iterator_type type;
92 };
93
94 } // namespace boost
95
96
97 // 2b. Adapt to Boost.Range, part 2, ADP
98
99 template<typename Item>
100 inline typename all_custom_container<Item>::custom_iterator_type
101 range_begin(all_custom_container<Item>& container)
102 {
103 return container.custom_begin();
104 }
105
106 template<typename Item>
107 inline typename all_custom_container<Item>::custom_const_iterator_type
108 range_begin(all_custom_container<Item> const& container)
109 {
110 return container.custom_begin();
111 }
112
113 template<typename Item>
114 inline typename all_custom_container<Item>::custom_iterator_type
115 range_end(all_custom_container<Item>& container)
116 {
117 return container.custom_end();
118 }
119
120 template<typename Item>
121 inline typename all_custom_container<Item>::custom_const_iterator_type
122 range_end(all_custom_container<Item> const& container)
123 {
124 return container.custom_end();
125 }
126
127 // (Optional)
128 template<typename Item>
129 inline std::size_t range_calculate_size(all_custom_container<Item> const& container)
130 {
131 return container.custom_size();
132 }
133
134
135
136
137 #endif // GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_CONTAINER_HPP