]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/test_geometries/wrapped_boost_array.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / test_geometries / wrapped_boost_array.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
4// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
1e59de90
TL
6// This file was modified by Oracle on 2020.
7// Modifications copyright (c) 2020 Oracle and/or its affiliates.
8// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
7c673cae
FG
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14
15#ifndef GEOMETRY_TEST_TEST_GEOMETRIES_WRAPPED_BOOST_ARRAY_HPP
16#define GEOMETRY_TEST_TEST_GEOMETRIES_WRAPPED_BOOST_ARRAY_HPP
17
18#include <cstddef>
19
20#include <boost/array.hpp>
1e59de90 21#include <boost/range/iterator.hpp>
7c673cae
FG
22
23#include <boost/geometry/core/mutable_range.hpp>
24#include <boost/geometry/core/tag.hpp>
25#include <boost/geometry/core/tags.hpp>
26
27
28namespace test
29{
30
31template <typename Point, std::size_t Count>
32struct wrapped_boost_array
33{
34 inline wrapped_boost_array() : size(0) {}
35
36 boost::array<Point, Count> array;
37 std::size_t size;
38};
39
40
41} // namespace test
42
43
44// 1a: adapt to Boost.Range
45namespace boost
46{
47 using namespace test;
48
49 template <typename Point, std::size_t Count>
50 struct range_mutable_iterator<wrapped_boost_array<Point, Count> >
51 : public range_mutable_iterator<boost::array<Point, Count> >
52 {};
53
54 template <typename Point, std::size_t Count>
55 struct range_const_iterator<wrapped_boost_array<Point, Count> >
56 : public range_const_iterator<boost::array<Point, Count> >
57 {};
58
59
60} // namespace 'boost'
61
62
63// 1b) adapt to Boost.Range with ADP
64namespace test
65{
66 template <typename Point, std::size_t Count>
67 inline typename boost::range_iterator
68 <
69 wrapped_boost_array<Point, Count>
70 >::type range_begin(wrapped_boost_array<Point, Count>& ar)
71 {
72 return ar.array.begin();
73 }
74
75 template <typename Point, std::size_t Count>
76 inline typename boost::range_iterator
77 <
78 wrapped_boost_array<Point, Count> const
79 >::type range_begin(wrapped_boost_array<Point, Count> const& ar)
80 {
81 return ar.array.begin();
82 }
83
84 template <typename Point, std::size_t Count>
85 inline typename boost::range_iterator
86 <
87 wrapped_boost_array<Point, Count>
88 >::type range_end(wrapped_boost_array<Point, Count>& ar)
89 {
90 typename boost::range_iterator
91 <
92 wrapped_boost_array<Point, Count>
93 >::type it = ar.array.begin();
94 return it + ar.size;
95 }
96
97 template <typename Point, std::size_t Count>
98 inline typename boost::range_iterator
99 <
100 wrapped_boost_array<Point, Count> const
101 >::type range_end(wrapped_boost_array<Point, Count> const& ar)
102 {
103 typename boost::range_iterator
104 <
105 wrapped_boost_array<Point, Count> const
106 >::type it = ar.array.begin();
107 return it + ar.size;
108 }
109
110}
111
112
113// 2: adapt to Boost.Geometry
114namespace boost { namespace geometry { namespace traits
115{
116
117 template <typename Point, std::size_t Count>
118 struct tag< wrapped_boost_array<Point, Count> >
119 {
120 typedef linestring_tag type;
121 };
122
123 template <typename Point, std::size_t Count>
124 struct clear< wrapped_boost_array<Point, Count> >
125 {
126 static inline void apply(wrapped_boost_array<Point, Count>& ar)
127 {
128 ar.size = 0;
129 }
130 };
131
132 template <typename Point, std::size_t Count>
133 struct push_back< wrapped_boost_array<Point, Count> >
134 {
135 static inline void apply(wrapped_boost_array<Point, Count>& ar, Point const& point)
136 {
137 // BOOST_ASSERT((ar.size < Count));
138 ar.array[ar.size++] = point;
139 }
140 };
141
142 template <typename Point, std::size_t Count>
143 struct resize< wrapped_boost_array<Point, Count> >
144 {
145 static inline void apply(wrapped_boost_array<Point, Count>& ar, std::size_t new_size)
146 {
147 BOOST_ASSERT(new_size < Count);
148 ar.size = new_size;
149 }
150 };
151
152}}} // namespace bg::traits
153
154
155#endif // GEOMETRY_TEST_TEST_GEOMETRIES_WRAPPED_BOOST_ARRAY_HPP