Boost.Geometry.Index

- Main Page
- Modules
- Classes
- Files

- File List

/home/travis/build/boostorg/boost/boost/geometry/index/indexable.hpp

    00001 // Boost.Geometry Index
    00002 //
    00003 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
    00004 //
    00005 // Use, modification and distribution is subject to the Boost Software License,
    00006 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    00007 // http://www.boost.org/LICENSE_1_0.txt)
    00008
    00009 #ifndef BOOST_GEOMETRY_INDEX_INDEXABLE_HPP
    00010 #define BOOST_GEOMETRY_INDEX_INDEXABLE_HPP
    00011
    00012 #include <boost/mpl/assert.hpp>
    00013
    00014 #include <boost/geometry/index/detail/is_indexable.hpp>
    00015
    00016 namespace boost { namespace geometry { namespace index { namespace detail {
    00017
    00028 template <typename Value, bool IsIndexable = is_indexable<Value>::value>
    00029 struct indexable
    00030 {
    00031     BOOST_MPL_ASSERT_MSG(
    00032         (detail::is_indexable<Value>::value),
    00033         NOT_VALID_INDEXABLE_TYPE,
    00034         (Value)
    00035     );
    00036
    00038     typedef Value const& result_type;
    00039
    00046     inline result_type operator()(Value const& v) const
    00047     {
    00048         return v;
    00049     }
    00050 };
    00051
    00060 template <typename Indexable, typename T2>
    00061 struct indexable<std::pair<Indexable, T2>, false>
    00062 {
    00063     BOOST_MPL_ASSERT_MSG(
    00064         (detail::is_indexable<Indexable>::value),
    00065         NOT_VALID_INDEXABLE_TYPE,
    00066         (Indexable)
    00067     );
    00068
    00070     typedef Indexable const& result_type;
    00071
    00078     inline result_type operator()(std::pair<Indexable, T2> const& v) const
    00079     {
    00080         return v.first;
    00081     }
    00082 };
    00083
    00091 template <typename Indexable, typename T1, typename T2, typename T3, typename T4,
    00092           typename T5, typename T6, typename T7, typename T8, typename T9>
    00093 struct indexable<boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9>, false>
    00094 {
    00095     typedef boost::tuple<Indexable, T1, T2, T3, T4, T5, T6, T7, T8, T9> value_type;
    00096
    00097     BOOST_MPL_ASSERT_MSG(
    00098         (detail::is_indexable<Indexable>::value),
    00099         NOT_VALID_INDEXABLE_TYPE,
    00100         (Indexable)
    00101         );
    00102
    00104     typedef Indexable const& result_type;
    00105
    00112     inline result_type operator()(value_type const& v) const
    00113     {
    00114         return boost::get<0>(v);
    00115     }
    00116 };
    00117
    00118 }}}} // namespace boost::geometry::index::detail
    00119
    00120 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
    00121
    00122 #include <tuple>
    00123
    00124 namespace boost { namespace geometry { namespace index { namespace detail {
    00125
    00134 template <typename Indexable, typename ...Args>
    00135 struct indexable<std::tuple<Indexable, Args...>, false>
    00136 {
    00137     typedef std::tuple<Indexable, Args...> value_type;
    00138
    00139     BOOST_MPL_ASSERT_MSG(
    00140         (detail::is_indexable<Indexable>::value),
    00141         NOT_VALID_INDEXABLE_TYPE,
    00142         (Indexable)
    00143         );
    00144
    00146     typedef Indexable const& result_type;
    00147
    00154     result_type operator()(value_type const& v) const
    00155     {
    00156         return std::get<0>(v);
    00157     }
    00158 };
    00159
    00160 }}}} // namespace boost::geometry::index::detail
    00161
    00162 #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
    00163
    00164 namespace boost { namespace geometry { namespace index {
    00165
    00175 template <typename Value>
    00176 struct indexable
    00177     : detail::indexable<Value>
    00178 {
    00180     typedef typename detail::indexable<Value>::result_type result_type;
    00181
    00188     inline result_type operator()(Value const& v) const
    00189     {
    00190         return detail::indexable<Value>::operator()(v);
    00191     }
    00192 };
    00193
    00194 }}} // namespace boost::geometry::index
    00195
    00196 #endif // BOOST_GEOMETRY_INDEX_INDEXABLE_HPP

All Classes Functions Typedefs