Mercurial > hg > vamp-build-and-test
diff 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 |
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/geometry/index/indexable.hpp Fri Sep 04 12:01:02 2015 +0100 +++ b/DEPENDENCIES/generic/include/boost/geometry/index/indexable.hpp Mon Sep 07 11:12:49 2015 +0100 @@ -1,6 +1,6 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -11,9 +11,7 @@ #include <boost/mpl/assert.hpp> -namespace boost { namespace geometry { namespace index { - -namespace detail { +namespace boost { namespace geometry { namespace index { namespace detail { template <typename Geometry, typename GeometryTag> struct is_indexable_impl { static const bool value = false; }; @@ -24,24 +22,31 @@ template <typename Box> struct is_indexable_impl<Box, geometry::box_tag> { static const bool value = true; }; +template <typename Segment> +struct is_indexable_impl<Segment, geometry::segment_tag> { static const bool value = true; }; + template <typename Indexable> struct is_indexable { static const bool value = - is_indexable_impl<Indexable, typename geometry::traits::tag<Indexable>::type>::value; + is_indexable_impl + < + Indexable, + typename geometry::tag<Indexable>::type + >::value; }; -} // namespace detail - /*! \brief The function object extracting Indexable from Value. It translates Value object to Indexable object. The default version handles Values which are Indexables. -This template is also specialized for std::pair<Indexable, T2> and boost::tuple<Indexable, ...>. +This template is also specialized for std::pair<Indexable, T2>, boost::tuple<Indexable, ...> +and std::tuple<Indexable, ...>. \tparam Value The Value type which may be translated directly to the Indexable. +\tparam IsIndexable If true, the const reference to Value is returned. */ -template <typename Value> +template <typename Value, bool IsIndexable = is_indexable<Value>::value> struct indexable { BOOST_MPL_ASSERT_MSG( @@ -49,6 +54,7 @@ NOT_VALID_INDEXABLE_TYPE, (Value) ); + /*! \brief The type of result returned by function object. */ typedef Value const& result_type; @@ -58,7 +64,7 @@ \param v The value. \return The indexable. */ - result_type operator()(Value const& v) const + inline result_type operator()(Value const& v) const { return v; } @@ -73,7 +79,7 @@ \tparam T2 The second type. */ template <typename Indexable, typename T2> -struct indexable< std::pair<Indexable, T2> > +struct indexable<std::pair<Indexable, T2>, false> { BOOST_MPL_ASSERT_MSG( (detail::is_indexable<Indexable>::value), @@ -90,7 +96,7 @@ \param v The value. \return The indexable. */ - result_type operator()(std::pair<Indexable, T2> const& v) const + inline result_type operator()(std::pair<Indexable, T2> const& v) const { return v.first; } @@ -105,7 +111,7 @@ */ 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> > +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; @@ -124,19 +130,19 @@ \param v The value. \return The indexable. */ - result_type operator()(value_type const& v) const + inline result_type operator()(value_type const& v) const { return boost::get<0>(v); } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include <tuple> -namespace boost { namespace geometry { namespace index { +namespace boost { namespace geometry { namespace index { namespace detail { /*! \brief The function object extracting Indexable from Value. @@ -147,7 +153,7 @@ \tparam Indexable The Indexable type. */ template <typename Indexable, typename ...Args> -struct indexable< std::tuple<Indexable, Args...> > +struct indexable<std::tuple<Indexable, Args...>, false> { typedef std::tuple<Indexable, Args...> value_type; @@ -172,8 +178,40 @@ } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +namespace boost { namespace geometry { namespace index { + +/*! +\brief The function object extracting Indexable from Value. + +It translates Value object to Indexable object. By default, it can handle Values which are Indexables, +std::pair<Indexable, T2>, boost::tuple<Indexable, ...> and std::tuple<Indexable, ...> if STD tuples +and variadic templates are supported. + +\tparam Value The Value type which may be translated directly to the Indexable. +*/ +template <typename Value> +struct indexable + : detail::indexable<Value> +{ + /*! \brief The type of result returned by function object. It should be const Indexable reference. */ + typedef typename detail::indexable<Value>::result_type result_type; + + /*! + \brief Return indexable extracted from the value. + + \param v The value. + \return The indexable. + */ + inline result_type operator()(Value const& v) const + { + return detail::indexable<Value>::operator()(v); + } +}; + +}}} // namespace boost::geometry::index + #endif // BOOST_GEOMETRY_INDEX_INDEXABLE_HPP