From 7978fc6c95db0fccf66a96abd477825cb8f2a465 Mon Sep 17 00:00:00 2001 From: Bruno Lalande Date: Tue, 5 Jun 2012 18:41:43 +0000 Subject: [PATCH] Made dispatch::equals more self-contained. [SVN r78817] --- include/boost/geometry/algorithms/equals.hpp | 89 +++++++------------- 1 file changed, 31 insertions(+), 58 deletions(-) diff --git a/include/boost/geometry/algorithms/equals.hpp b/include/boost/geometry/algorithms/equals.hpp index 6b094f76d..4a2d2d93b 100644 --- a/include/boost/geometry/algorithms/equals.hpp +++ b/include/boost/geometry/algorithms/equals.hpp @@ -51,13 +51,12 @@ namespace detail { namespace equals template < - typename Box1, - typename Box2, std::size_t Dimension, std::size_t DimensionCount > struct box_box { + template static inline bool apply(Box1 const& box1, Box2 const& box2) { if (!geometry::math::equals(get(box1), get(box2)) @@ -65,13 +64,14 @@ struct box_box { return false; } - return box_box::apply(box1, box2); + return box_box::apply(box1, box2); } }; -template -struct box_box +template +struct box_box { + template static inline bool apply(Box1 const& , Box2 const& ) { return true; @@ -103,9 +103,10 @@ struct length_check }; -template +template struct equals_by_collection { + template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2) { if (! TrivialCheck::apply(geometry1, geometry2)) @@ -152,17 +153,18 @@ namespace dispatch template < - typename Tag1, typename Tag2, typename Geometry1, typename Geometry2, - std::size_t DimensionCount + typename Tag1 = typename tag::type, + typename Tag2 = typename tag::type, + std::size_t DimensionCount = dimension::type::value > struct equals {}; template -struct equals +struct equals : geometry::detail::not_ < P1, @@ -173,77 +175,54 @@ struct equals template -struct equals - : detail::equals::box_box +struct equals + : detail::equals::box_box<0, DimensionCount> {}; template -struct equals - : detail::equals::equals_by_collection - < - Ring1, Ring2, - detail::equals::area_check - > +struct equals + : detail::equals::equals_by_collection {}; template -struct equals - : detail::equals::equals_by_collection - < - Polygon1, Polygon2, - detail::equals::area_check - > +struct equals + : detail::equals::equals_by_collection {}; template -struct equals - : detail::equals::equals_by_collection - < - LineString1, LineString2, - detail::equals::length_check - > +struct equals + : detail::equals::equals_by_collection {}; template -struct equals - : detail::equals::equals_by_collection - < - Polygon, Ring, - detail::equals::area_check - > +struct equals + : detail::equals::equals_by_collection {}; template -struct equals - : detail::equals::equals_by_collection - < - Ring, Box, - detail::equals::area_check - > +struct equals + : detail::equals::equals_by_collection {}; template -struct equals - : detail::equals::equals_by_collection - < - Polygon, Box, - detail::equals::area_check - > +struct equals + : detail::equals::equals_by_collection {}; template < - typename Tag1, typename Tag2, typename Geometry1, typename Geometry2, - std::size_t DimensionCount + typename Tag1 = typename tag::type, + typename Tag2 = typename tag::type, + std::size_t DimensionCount = dimension::type::value > struct equals_reversed { @@ -251,8 +230,8 @@ struct equals_reversed { return equals < - Tag2, Tag1, Geometry2, Geometry1, + Tag2, Tag1, DimensionCount >::apply(g2, g1); } @@ -294,19 +273,13 @@ inline bool equals(Geometry1 const& geometry1, Geometry2 const& geometry2) reverse_dispatch::type::value, dispatch::equals_reversed < - typename tag::type, - typename tag::type, Geometry1, - Geometry2, - dimension::type::value + Geometry2 >, dispatch::equals < - typename tag::type, - typename tag::type, Geometry1, - Geometry2, - dimension::type::value + Geometry2 > >::type::apply(geometry1, geometry2); }