Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/index/indexable.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 // Boost.Geometry Index | 1 // Boost.Geometry Index |
2 // | 2 // |
3 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. | 3 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. |
4 // | 4 // |
5 // Use, modification and distribution is subject to the Boost Software License, | 5 // Use, modification and distribution is subject to the Boost Software License, |
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | 6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
7 // http://www.boost.org/LICENSE_1_0.txt) | 7 // http://www.boost.org/LICENSE_1_0.txt) |
8 | 8 |
9 #ifndef BOOST_GEOMETRY_INDEX_INDEXABLE_HPP | 9 #ifndef BOOST_GEOMETRY_INDEX_INDEXABLE_HPP |
10 #define BOOST_GEOMETRY_INDEX_INDEXABLE_HPP | 10 #define BOOST_GEOMETRY_INDEX_INDEXABLE_HPP |
11 | 11 |
12 #include <boost/mpl/assert.hpp> | 12 #include <boost/mpl/assert.hpp> |
13 | 13 |
14 namespace boost { namespace geometry { namespace index { | 14 namespace boost { namespace geometry { namespace index { namespace detail { |
15 | |
16 namespace detail { | |
17 | 15 |
18 template <typename Geometry, typename GeometryTag> | 16 template <typename Geometry, typename GeometryTag> |
19 struct is_indexable_impl { static const bool value = false; }; | 17 struct is_indexable_impl { static const bool value = false; }; |
20 | 18 |
21 template <typename Point> | 19 template <typename Point> |
22 struct is_indexable_impl<Point, geometry::point_tag> { static const bool value = true; }; | 20 struct is_indexable_impl<Point, geometry::point_tag> { static const bool value = true; }; |
23 | 21 |
24 template <typename Box> | 22 template <typename Box> |
25 struct is_indexable_impl<Box, geometry::box_tag> { static const bool value = true; }; | 23 struct is_indexable_impl<Box, geometry::box_tag> { static const bool value = true; }; |
26 | 24 |
25 template <typename Segment> | |
26 struct is_indexable_impl<Segment, geometry::segment_tag> { static const bool value = true; }; | |
27 | |
27 template <typename Indexable> | 28 template <typename Indexable> |
28 struct is_indexable | 29 struct is_indexable |
29 { | 30 { |
30 static const bool value = | 31 static const bool value = |
31 is_indexable_impl<Indexable, typename geometry::traits::tag<Indexable>::type>::value; | 32 is_indexable_impl |
32 }; | 33 < |
33 | 34 Indexable, |
34 } // namespace detail | 35 typename geometry::tag<Indexable>::type |
36 >::value; | |
37 }; | |
35 | 38 |
36 /*! | 39 /*! |
37 \brief The function object extracting Indexable from Value. | 40 \brief The function object extracting Indexable from Value. |
38 | 41 |
39 It translates Value object to Indexable object. The default version handles Values which are Indexables. | 42 It translates Value object to Indexable object. The default version handles Values which are Indexables. |
40 This template is also specialized for std::pair<Indexable, T2> and boost::tuple<Indexable, ...>. | 43 This template is also specialized for std::pair<Indexable, T2>, boost::tuple<Indexable, ...> |
44 and std::tuple<Indexable, ...>. | |
45 | |
46 \tparam Value The Value type which may be translated directly to the Indexable. | |
47 \tparam IsIndexable If true, the const reference to Value is returned. | |
48 */ | |
49 template <typename Value, bool IsIndexable = is_indexable<Value>::value> | |
50 struct indexable | |
51 { | |
52 BOOST_MPL_ASSERT_MSG( | |
53 (detail::is_indexable<Value>::value), | |
54 NOT_VALID_INDEXABLE_TYPE, | |
55 (Value) | |
56 ); | |
57 | |
58 /*! \brief The type of result returned by function object. */ | |
59 typedef Value const& result_type; | |
60 | |
61 /*! | |
62 \brief Return indexable extracted from the value. | |
63 | |
64 \param v The value. | |
65 \return The indexable. | |
66 */ | |
67 inline result_type operator()(Value const& v) const | |
68 { | |
69 return v; | |
70 } | |
71 }; | |
72 | |
73 /*! | |
74 \brief The function object extracting Indexable from Value. | |
75 | |
76 This specialization translates from std::pair<Indexable, T2>. | |
77 | |
78 \tparam Indexable The Indexable type. | |
79 \tparam T2 The second type. | |
80 */ | |
81 template <typename Indexable, typename T2> | |
82 struct indexable<std::pair<Indexable, T2>, false> | |
83 { | |
84 BOOST_MPL_ASSERT_MSG( | |
85 (detail::is_indexable<Indexable>::value), | |
86 NOT_VALID_INDEXABLE_TYPE, | |
87 (Indexable) | |
88 ); | |
89 | |
90 /*! \brief The type of result returned by function object. */ | |
91 typedef Indexable const& result_type; | |
92 | |
93 /*! | |
94 \brief Return indexable extracted from the value. | |
95 | |
96 \param v The value. | |
97 \return The indexable. | |
98 */ | |
99 inline result_type operator()(std::pair<Indexable, T2> const& v) const | |
100 { | |
101 return v.first; | |
102 } | |
103 }; | |
104 | |
105 /*! | |
106 \brief The function object extracting Indexable from Value. | |
107 | |
108 This specialization translates from boost::tuple<Indexable, ...>. | |
109 | |
110 \tparam Indexable The Indexable type. | |
111 */ | |
112 template <typename Indexable, typename T1, typename T2, typename T3, typename T4, | |
113 typename T5, typename T6, typename T7, typename T8, typename T9> | |
114 struct indexable<boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9>, false> | |
115 { | |
116 typedef boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9> value_type; | |
117 | |
118 BOOST_MPL_ASSERT_MSG( | |
119 (detail::is_indexable<Indexable>::value), | |
120 NOT_VALID_INDEXABLE_TYPE, | |
121 (Indexable) | |
122 ); | |
123 | |
124 /*! \brief The type of result returned by function object. */ | |
125 typedef Indexable const& result_type; | |
126 | |
127 /*! | |
128 \brief Return indexable extracted from the value. | |
129 | |
130 \param v The value. | |
131 \return The indexable. | |
132 */ | |
133 inline result_type operator()(value_type const& v) const | |
134 { | |
135 return boost::get<0>(v); | |
136 } | |
137 }; | |
138 | |
139 }}}} // namespace boost::geometry::index::detail | |
140 | |
141 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
142 | |
143 #include <tuple> | |
144 | |
145 namespace boost { namespace geometry { namespace index { namespace detail { | |
146 | |
147 /*! | |
148 \brief The function object extracting Indexable from Value. | |
149 | |
150 This specialization translates from std::tuple<Indexable, Args...>. | |
151 It's defined if the compiler supports tuples and variadic templates. | |
152 | |
153 \tparam Indexable The Indexable type. | |
154 */ | |
155 template <typename Indexable, typename ...Args> | |
156 struct indexable<std::tuple<Indexable, Args...>, false> | |
157 { | |
158 typedef std::tuple<Indexable, Args...> value_type; | |
159 | |
160 BOOST_MPL_ASSERT_MSG( | |
161 (detail::is_indexable<Indexable>::value), | |
162 NOT_VALID_INDEXABLE_TYPE, | |
163 (Indexable) | |
164 ); | |
165 | |
166 /*! \brief The type of result returned by function object. */ | |
167 typedef Indexable const& result_type; | |
168 | |
169 /*! | |
170 \brief Return indexable extracted from the value. | |
171 | |
172 \param v The value. | |
173 \return The indexable. | |
174 */ | |
175 result_type operator()(value_type const& v) const | |
176 { | |
177 return std::get<0>(v); | |
178 } | |
179 }; | |
180 | |
181 }}}} // namespace boost::geometry::index::detail | |
182 | |
183 #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
184 | |
185 namespace boost { namespace geometry { namespace index { | |
186 | |
187 /*! | |
188 \brief The function object extracting Indexable from Value. | |
189 | |
190 It translates Value object to Indexable object. By default, it can handle Values which are Indexables, | |
191 std::pair<Indexable, T2>, boost::tuple<Indexable, ...> and std::tuple<Indexable, ...> if STD tuples | |
192 and variadic templates are supported. | |
41 | 193 |
42 \tparam Value The Value type which may be translated directly to the Indexable. | 194 \tparam Value The Value type which may be translated directly to the Indexable. |
43 */ | 195 */ |
44 template <typename Value> | 196 template <typename Value> |
45 struct indexable | 197 struct indexable |
46 { | 198 : detail::indexable<Value> |
47 BOOST_MPL_ASSERT_MSG( | 199 { |
48 (detail::is_indexable<Value>::value), | 200 /*! \brief The type of result returned by function object. It should be const Indexable reference. */ |
49 NOT_VALID_INDEXABLE_TYPE, | 201 typedef typename detail::indexable<Value>::result_type result_type; |
50 (Value) | 202 |
51 ); | 203 /*! |
52 /*! \brief The type of result returned by function object. */ | 204 \brief Return indexable extracted from the value. |
53 typedef Value const& result_type; | 205 |
54 | 206 \param v The value. |
55 /*! | 207 \return The indexable. |
56 \brief Return indexable extracted from the value. | 208 */ |
57 | 209 inline result_type operator()(Value const& v) const |
58 \param v The value. | 210 { |
59 \return The indexable. | 211 return detail::indexable<Value>::operator()(v); |
60 */ | |
61 result_type operator()(Value const& v) const | |
62 { | |
63 return v; | |
64 } | |
65 }; | |
66 | |
67 /*! | |
68 \brief The function object extracting Indexable from Value. | |
69 | |
70 This specialization translates from std::pair<Indexable, T2>. | |
71 | |
72 \tparam Indexable The Indexable type. | |
73 \tparam T2 The second type. | |
74 */ | |
75 template <typename Indexable, typename T2> | |
76 struct indexable< std::pair<Indexable, T2> > | |
77 { | |
78 BOOST_MPL_ASSERT_MSG( | |
79 (detail::is_indexable<Indexable>::value), | |
80 NOT_VALID_INDEXABLE_TYPE, | |
81 (Indexable) | |
82 ); | |
83 | |
84 /*! \brief The type of result returned by function object. */ | |
85 typedef Indexable const& result_type; | |
86 | |
87 /*! | |
88 \brief Return indexable extracted from the value. | |
89 | |
90 \param v The value. | |
91 \return The indexable. | |
92 */ | |
93 result_type operator()(std::pair<Indexable, T2> const& v) const | |
94 { | |
95 return v.first; | |
96 } | |
97 }; | |
98 | |
99 /*! | |
100 \brief The function object extracting Indexable from Value. | |
101 | |
102 This specialization translates from boost::tuple<Indexable, ...>. | |
103 | |
104 \tparam Indexable The Indexable type. | |
105 */ | |
106 template <typename Indexable, typename T1, typename T2, typename T3, typename T4, | |
107 typename T5, typename T6, typename T7, typename T8, typename T9> | |
108 struct indexable< boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9> > | |
109 { | |
110 typedef boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9> value_type; | |
111 | |
112 BOOST_MPL_ASSERT_MSG( | |
113 (detail::is_indexable<Indexable>::value), | |
114 NOT_VALID_INDEXABLE_TYPE, | |
115 (Indexable) | |
116 ); | |
117 | |
118 /*! \brief The type of result returned by function object. */ | |
119 typedef Indexable const& result_type; | |
120 | |
121 /*! | |
122 \brief Return indexable extracted from the value. | |
123 | |
124 \param v The value. | |
125 \return The indexable. | |
126 */ | |
127 result_type operator()(value_type const& v) const | |
128 { | |
129 return boost::get<0>(v); | |
130 } | 212 } |
131 }; | 213 }; |
132 | 214 |
133 }}} // namespace boost::geometry::index | 215 }}} // namespace boost::geometry::index |
134 | 216 |
135 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
136 | |
137 #include <tuple> | |
138 | |
139 namespace boost { namespace geometry { namespace index { | |
140 | |
141 /*! | |
142 \brief The function object extracting Indexable from Value. | |
143 | |
144 This specialization translates from std::tuple<Indexable, Args...>. | |
145 It's defined if the compiler supports tuples and variadic templates. | |
146 | |
147 \tparam Indexable The Indexable type. | |
148 */ | |
149 template <typename Indexable, typename ...Args> | |
150 struct indexable< std::tuple<Indexable, Args...> > | |
151 { | |
152 typedef std::tuple<Indexable, Args...> value_type; | |
153 | |
154 BOOST_MPL_ASSERT_MSG( | |
155 (detail::is_indexable<Indexable>::value), | |
156 NOT_VALID_INDEXABLE_TYPE, | |
157 (Indexable) | |
158 ); | |
159 | |
160 /*! \brief The type of result returned by function object. */ | |
161 typedef Indexable const& result_type; | |
162 | |
163 /*! | |
164 \brief Return indexable extracted from the value. | |
165 | |
166 \param v The value. | |
167 \return The indexable. | |
168 */ | |
169 result_type operator()(value_type const& v) const | |
170 { | |
171 return std::get<0>(v); | |
172 } | |
173 }; | |
174 | |
175 }}} // namespace boost::geometry::index | |
176 | |
177 #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
178 | |
179 #endif // BOOST_GEOMETRY_INDEX_INDEXABLE_HPP | 217 #endif // BOOST_GEOMETRY_INDEX_INDEXABLE_HPP |