Boost.Geometry.Index
 All Classes Functions Typedefs Groups
indexable.hpp
1 // Boost.Geometry Index
2 //
3 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
4 //
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
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 #ifndef BOOST_GEOMETRY_INDEX_INDEXABLE_HPP
10 #define BOOST_GEOMETRY_INDEX_INDEXABLE_HPP
11 
12 #include <boost/mpl/assert.hpp>
13 
14 #include <boost/geometry/index/detail/is_indexable.hpp>
15 
16 namespace boost { namespace geometry { namespace index { namespace detail {
17 
28 template <typename Value, bool IsIndexable = is_indexable<Value>::value>
29 struct indexable
30 {
31  BOOST_MPL_ASSERT_MSG(
32  (detail::is_indexable<Value>::value),
33  NOT_VALID_INDEXABLE_TYPE,
34  (Value)
35  );
36 
38  typedef Value const& result_type;
39 
46  inline result_type operator()(Value const& v) const
47  {
48  return v;
49  }
50 };
51 
60 template <typename Indexable, typename T2>
61 struct indexable<std::pair<Indexable, T2>, false>
62 {
63  BOOST_MPL_ASSERT_MSG(
64  (detail::is_indexable<Indexable>::value),
65  NOT_VALID_INDEXABLE_TYPE,
66  (Indexable)
67  );
68 
70  typedef Indexable const& result_type;
71 
78  inline result_type operator()(std::pair<Indexable, T2> const& v) const
79  {
80  return v.first;
81  }
82 };
83 
91 template <typename Indexable, typename T1, typename T2, typename T3, typename T4,
92  typename T5, typename T6, typename T7, typename T8, typename T9>
93 struct indexable<boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9>, false>
94 {
95  typedef boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9> value_type;
96 
97  BOOST_MPL_ASSERT_MSG(
98  (detail::is_indexable<Indexable>::value),
99  NOT_VALID_INDEXABLE_TYPE,
100  (Indexable)
101  );
102 
104  typedef Indexable const& result_type;
105 
112  inline result_type operator()(value_type const& v) const
113  {
114  return boost::get<0>(v);
115  }
116 };
117 
118 }}}} // namespace boost::geometry::index::detail
119 
120 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
121 
122 #include <tuple>
123 
124 namespace boost { namespace geometry { namespace index { namespace detail {
125 
134 template <typename Indexable, typename ...Args>
135 struct indexable<std::tuple<Indexable, Args...>, false>
136 {
137  typedef std::tuple<Indexable, Args...> value_type;
138 
139  BOOST_MPL_ASSERT_MSG(
140  (detail::is_indexable<Indexable>::value),
141  NOT_VALID_INDEXABLE_TYPE,
142  (Indexable)
143  );
144 
146  typedef Indexable const& result_type;
147 
154  result_type operator()(value_type const& v) const
155  {
156  return std::get<0>(v);
157  }
158 };
159 
160 }}}} // namespace boost::geometry::index::detail
161 
162 #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
163 
164 namespace boost { namespace geometry { namespace index {
165 
175 template <typename Value>
176 struct indexable
177  : detail::indexable<Value>
178 {
181 
188  inline result_type operator()(Value const& v) const
189  {
191  }
192 };
193 
194 }}} // namespace boost::geometry::index
195 
196 #endif // BOOST_GEOMETRY_INDEX_INDEXABLE_HPP
The function object extracting Indexable from Value.
Definition: indexable.hpp:176
Indexable const & result_type
The type of result returned by function object.
Definition: indexable.hpp:70
result_type operator()(value_type const &v) const
Return indexable extracted from the value.
Definition: indexable.hpp:112
The function object extracting Indexable from Value.
Definition: indexable.hpp:29
detail::indexable< Value >::result_type result_type
The type of result returned by function object. It should be const Indexable reference.
Definition: indexable.hpp:180
result_type operator()(Value const &v) const
Return indexable extracted from the value.
Definition: indexable.hpp:188
Indexable const & result_type
The type of result returned by function object.
Definition: indexable.hpp:104
Value const & result_type
The type of result returned by function object.
Definition: indexable.hpp:38
result_type operator()(value_type const &v) const
Return indexable extracted from the value.
Definition: indexable.hpp:154
result_type operator()(Value const &v) const
Return indexable extracted from the value.
Definition: indexable.hpp:46
Indexable const & result_type
The type of result returned by function object.
Definition: indexable.hpp:146
result_type operator()(std::pair< Indexable, T2 > const &v) const
Return indexable extracted from the value.
Definition: indexable.hpp:78