// Boost.Geometry Index // // Copyright (c) 2011-2013 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 // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_INDEX_DETAIL_TUPLES_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_TUPLES_HPP #include #include // TODO move this to index/tuples and separate algorithms namespace boost { namespace geometry { namespace index { namespace detail { namespace tuples { // find_index namespace detail { template struct find_index; template struct find_index_impl { static const size_t value = find_index::value; }; template struct find_index_impl { static const size_t value = N - 1; }; template struct find_index_impl { BOOST_MPL_ASSERT_MSG( (false), ELEMENT_NOT_FOUND, (find_index_impl)); }; template struct find_index_impl { static const size_t value = 0; }; template struct find_index { static const size_t value = find_index_impl< Tuple, El, N, typename boost::tuples::element::type >::value; }; } // namespace detail template struct find_index { static const size_t value = detail::find_index< Tuple, El, boost::tuples::length::value >::value; }; // has namespace detail { template struct has { static const bool value = boost::is_same< typename boost::tuples::element::type, El >::value || has::value; }; template struct has { static const bool value = boost::is_same< typename boost::tuples::element<0, Tuple>::type, El >::value; }; } // namespace detail template struct has { static const bool value = detail::has< Tuple, El, boost::tuples::length::value >::value; }; // add template struct add { BOOST_MPL_ASSERT_MSG( (false), NOT_IMPLEMENTED_FOR_THIS_TUPLE_TYPE, (add)); }; template struct add, T> { typedef boost::tuple type; }; template struct add, T> { typedef boost::tuple type; }; // add_if template struct add_if { typedef Tuple type; }; template struct add_if { typedef typename add::type type; }; // add_unique template struct add_unique { typedef typename add_if< Tuple, El, !has::value >::type type; }; template ::value> struct push_back { typedef boost::tuples::cons< typename boost::tuples::element::type, typename push_back::type > type; static type apply(Tuple const& tup, T const& t) { return type( boost::get(tup), push_back::apply(tup, t) ); } }; template struct push_back { typedef boost::tuples::cons type; static type apply(Tuple const&, T const& t) { return type(t, boost::tuples::null_type()); } }; } // namespace tuples }}}} // namespace boost::geometry::index::detail #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_TAGS_HPP