From 15e85e390db92203e3c5d4ed4573f675f7f4ecb3 Mon Sep 17 00:00:00 2001 From: Bruno Lalande Date: Mon, 4 Jun 2012 17:57:21 +0000 Subject: [PATCH] Moved more template params from class to function level in intersection. [SVN r78808] --- .../geometry/algorithms/intersection.hpp | 104 ++++++++---------- 1 file changed, 46 insertions(+), 58 deletions(-) diff --git a/include/boost/geometry/algorithms/intersection.hpp b/include/boost/geometry/algorithms/intersection.hpp index 774a390c4..c6db6a58c 100644 --- a/include/boost/geometry/algorithms/intersection.hpp +++ b/include/boost/geometry/algorithms/intersection.hpp @@ -25,12 +25,11 @@ namespace detail { namespace intersection template < typename Box1, typename Box2, - typename BoxOut, std::size_t Dimension, std::size_t DimensionCount > struct intersection_box_box { - template + template static inline bool apply(Box1 const& box1, Box2 const& box2, BoxOut& box_out, Strategy const& strategy) @@ -52,7 +51,7 @@ struct intersection_box_box return intersection_box_box < - Box1, Box2, BoxOut, + Box1, Box2, Dimension + 1, DimensionCount >::apply(box1, box2, box_out, strategy); } @@ -61,12 +60,11 @@ struct intersection_box_box template < typename Box1, typename Box2, - typename BoxOut, std::size_t DimensionCount > -struct intersection_box_box +struct intersection_box_box { - template + template static inline bool apply(Box1 const&, Box2 const&, BoxOut&, Strategy const&) { return true; @@ -86,20 +84,20 @@ namespace dispatch // By default, all is forwarded to the intersection_insert-dispatcher template < - typename Tag1, typename Tag2, typename TagOut, typename Geometry1, typename Geometry2, - typename GeometryOut + typename Tag1 = typename geometry::tag::type, + typename Tag2 = typename geometry::tag::type, + bool Reverse = reverse_dispatch::type::value > struct intersection { - typedef std::back_insert_iterator output_iterator; - - template + template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, GeometryOut& geometry_out, Strategy const& strategy) { + typedef std::back_insert_iterator output_iterator; typedef typename boost::range_value::type OneOut; intersection_insert @@ -123,47 +121,51 @@ struct intersection }; +// If reversal is needed, perform it template < - typename Box1, typename Box2, - typename BoxOut + typename Geometry1, typename Geometry2, + typename Tag1, typename Tag2 > struct intersection - < - box_tag, box_tag, box_tag, - Box1, Box2, BoxOut - > : public detail::intersection::intersection_box_box - < - Box1, Box2, BoxOut, - 0, geometry::dimension::value - > -{}; - - -template < - typename Tag1, typename Tag2, typename TagOut, - typename Geometry1, typename Geometry2, - typename GeometryOut + Geometry1, Geometry2, + Tag1, Tag2, + true > -struct intersection_reversed + : intersection { - template - static inline bool apply(Geometry1 const& geometry1, - Geometry2 const& geometry2, - GeometryOut& geometry_out, - Strategy const& strategy) + template + static inline bool apply( + Geometry1 const& g1, + Geometry2 const& g2, + GeometryOut& out, + Strategy const& strategy) { - return intersection - < - Tag2, Tag1, TagOut, - Geometry2, Geometry1, - GeometryOut - >::apply(geometry2, geometry1, geometry_out, strategy); + return intersection< + Geometry2, Geometry1, + Tag2, Tag1, + false + >::apply(g2, g1, out, strategy); } }; +template +< + typename Box1, typename Box2, bool Reverse +> +struct intersection + < + Box1, Box2, + box_tag, box_tag, + Reverse + > : public detail::intersection::intersection_box_box + < + Box1, Box2, + 0, geometry::dimension::value + > +{}; } // namespace dispatch @@ -207,24 +209,10 @@ inline bool intersection(Geometry1 const& geometry1, > strategy; - return boost::mpl::if_c - < - geometry::reverse_dispatch::type::value, - dispatch::intersection_reversed - < - typename geometry::tag::type, - typename geometry::tag::type, - typename geometry::tag::type, - Geometry1, Geometry2, GeometryOut - >, - dispatch::intersection - < - typename geometry::tag::type, - typename geometry::tag::type, - typename geometry::tag::type, - Geometry1, Geometry2, GeometryOut - > - >::type::apply(geometry1, geometry2, geometry_out, strategy()); + return dispatch::intersection< + Geometry1, + Geometry2 + >::apply(geometry1, geometry2, geometry_out, strategy()); }