From 325dbe203bda4b3baf464e95ee9ba31a17c14e1a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 8 Jul 2014 12:34:56 +0300 Subject: [PATCH] [strategies][distance (result)] polish code a bit; eliminate result_of namespaces; replace result_of::distance by distance_result; add support for comparable distances (i.e., add specializations for default_comparable_strategy); qualify occurences of variant with boost:: ; fix bug: when resolving strategies, pass actual geometries instead of their point types (important in order to return the actual/correct strategy return type); --- .../geometry/strategies/distance_result.hpp | 106 +++++++++++++----- 1 file changed, 75 insertions(+), 31 deletions(-) diff --git a/include/boost/geometry/strategies/distance_result.hpp b/include/boost/geometry/strategies/distance_result.hpp index 88486079f..1fe1597d3 100644 --- a/include/boost/geometry/strategies/distance_result.hpp +++ b/include/boost/geometry/strategies/distance_result.hpp @@ -43,11 +43,11 @@ namespace boost { namespace geometry { -namespace resolve_strategy { namespace result_of +namespace resolve_strategy { template -struct distance +struct distance_result : strategy::distance::services::return_type < Strategy, @@ -57,8 +57,8 @@ struct distance {}; template -struct distance - : distance +struct distance_result + : distance_result < Geometry1, Geometry2, @@ -69,15 +69,31 @@ struct distance > {}; -}} // namespace resolve_strategy::result_of +template +struct distance_result + : distance_result + < + Geometry1, + Geometry2, + typename strategy::distance::services::comparable_type + < + typename detail::distance::default_strategy + < + Geometry1, Geometry2 + >::type + >::type + > +{}; + +} // namespace resolve_strategy -namespace resolve_variant { namespace result_of +namespace resolve_variant { template -struct distance - : resolve_strategy::result_of::distance +struct distance_result + : resolve_strategy::distance_result < Geometry1, Geometry2, @@ -86,15 +102,24 @@ struct distance {}; -template -struct distance, Strategy> +template +< + typename Geometry1, + BOOST_VARIANT_ENUM_PARAMS(typename T), + typename Strategy +> +struct distance_result + < + Geometry1, variant, Strategy + > { - // A set of all variant type combinations that are compatible and implemented + // A set of all variant type combinations that are compatible and + // implemented typedef typename util::combine_if< typename mpl::vector1, typename variant::types, - // Here we want should remove most of the combinations that are not valid - // mostly to limit the size of the resulting MPL set. + // Here we want should remove most of the combinations that + // are not valid, mostly to limit the size of the resulting MPL set. // But is_implementedn is not ready for prime time // // util::is_implemented2 > @@ -105,9 +130,9 @@ struct distance, Strategy> typedef typename compress_variant< typename transform_variant< possible_input_types, - resolve_strategy::result_of::distance< - point_type >, - point_type >, + resolve_strategy::distance_result< + mpl::first, + mpl::second, Strategy >, mpl::back_inserter > @@ -117,23 +142,42 @@ struct distance, Strategy> // Distance arguments are commutative -template -struct distance, Geometry2, Strategy> - : public distance, Strategy> +template +< + BOOST_VARIANT_ENUM_PARAMS(typename T), + typename Geometry2, + typename Strategy +> +struct distance_result + < + boost::variant, + Geometry2, + Strategy + > : public distance_result + < + Geometry2, boost::variant, Strategy + > {}; template -struct distance, variant, Strategy> +struct distance_result + < + boost::variant, + boost::variant, + Strategy + > { - // A set of all variant type combinations that are compatible and implemented + // A set of all variant type combinations that are compatible and + // implemented typedef typename util::combine_if < - typename variant::types, - typename variant::types, - // Here we want to try to remove most of the combinations that are not valid - // mostly to limit the size of the resulting MPL vector. - // But is_implementedn is not ready for prime time + typename boost::variant::types, + typename boost::variant::types, + // Here we want to try to remove most of the combinations + // that are not valid, mostly to limit the size of the + // resulting MPL vector. + // But is_implemented is not ready for prime time // // util::is_implemented2 > mpl::always @@ -143,9 +187,9 @@ struct distance, variant >, - point_type >, + resolve_strategy::distance_result< + mpl::first, + mpl::second, Strategy >, mpl::back_inserter > @@ -153,7 +197,7 @@ struct distance, variant::type type; }; -}} // namespace resolve_variant::result_of +} // namespace resolve_variant /*! @@ -169,7 +213,7 @@ template typename Strategy = void > struct distance_result - : resolve_variant::result_of::distance + : resolve_variant::distance_result {};