123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #ifndef BOOST_GEOMETRY_INDEX_INDEXABLE_HPP
- #define BOOST_GEOMETRY_INDEX_INDEXABLE_HPP
- #include <boost/mpl/assert.hpp>
- #include <boost/geometry/index/detail/is_indexable.hpp>
- namespace boost { namespace geometry { namespace index { namespace detail {
- template <typename Value, bool IsIndexable = is_indexable<Value>::value>
- struct indexable
- {
- BOOST_MPL_ASSERT_MSG(
- (detail::is_indexable<Value>::value),
- NOT_VALID_INDEXABLE_TYPE,
- (Value)
- );
-
- typedef Value const& result_type;
-
- inline result_type operator()(Value const& v) const
- {
- return v;
- }
- };
- template <typename Indexable, typename T2>
- struct indexable<std::pair<Indexable, T2>, false>
- {
- BOOST_MPL_ASSERT_MSG(
- (detail::is_indexable<Indexable>::value),
- NOT_VALID_INDEXABLE_TYPE,
- (Indexable)
- );
-
- typedef Indexable const& result_type;
-
- inline result_type operator()(std::pair<Indexable, T2> const& v) const
- {
- return v.first;
- }
- };
- template <typename Indexable, typename T1, typename T2, typename T3, typename T4,
- typename T5, typename T6, typename T7, typename T8, typename T9>
- struct indexable<boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9>, false>
- {
- typedef boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9> value_type;
- BOOST_MPL_ASSERT_MSG(
- (detail::is_indexable<Indexable>::value),
- NOT_VALID_INDEXABLE_TYPE,
- (Indexable)
- );
-
- typedef Indexable const& result_type;
-
- inline result_type operator()(value_type const& v) const
- {
- return boost::get<0>(v);
- }
- };
- }}}}
- #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
- #include <tuple>
- namespace boost { namespace geometry { namespace index { namespace detail {
- template <typename Indexable, typename ...Args>
- struct indexable<std::tuple<Indexable, Args...>, false>
- {
- typedef std::tuple<Indexable, Args...> value_type;
- BOOST_MPL_ASSERT_MSG(
- (detail::is_indexable<Indexable>::value),
- NOT_VALID_INDEXABLE_TYPE,
- (Indexable)
- );
-
- typedef Indexable const& result_type;
-
- result_type operator()(value_type const& v) const
- {
- return std::get<0>(v);
- }
- };
- }}}}
- #endif
- namespace boost { namespace geometry { namespace index {
- template <typename Value>
- struct indexable
- : detail::indexable<Value>
- {
-
- typedef typename detail::indexable<Value>::result_type result_type;
-
- inline result_type operator()(Value const& v) const
- {
- return detail::indexable<Value>::operator()(v);
- }
- };
- }}}
- #endif
|