Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81075 - in trunk/boost/geometry: algorithms multi/algorithms
From: bruno.lalande_at_[hidden]
Date: 2012-10-28 15:08:35


Author: bruno.lalande
Date: 2012-10-28 15:08:35 EDT (Sun, 28 Oct 2012)
New Revision: 81075
URL: http://svn.boost.org/trac/boost/changeset/81075

Log:
Made dispatch::num_points able to find the tag by itself + used not_implemented.
Text files modified:
   trunk/boost/geometry/algorithms/num_points.hpp | 61 ++++++++++++++++++---------------------
   trunk/boost/geometry/multi/algorithms/num_points.hpp | 12 ++-----
   2 files changed, 32 insertions(+), 41 deletions(-)

Modified: trunk/boost/geometry/algorithms/num_points.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/num_points.hpp (original)
+++ trunk/boost/geometry/algorithms/num_points.hpp 2012-10-28 15:08:35 EDT (Sun, 28 Oct 2012)
@@ -16,7 +16,6 @@
 
 #include <cstddef>
 
-#include <boost/mpl/assert.hpp>
 #include <boost/range.hpp>
 #include <boost/typeof/typeof.hpp>
 
@@ -27,6 +26,7 @@
 #include <boost/geometry/core/tag_cast.hpp>
 
 #include <boost/geometry/algorithms/disjoint.hpp>
+#include <boost/geometry/algorithms/not_implemented.hpp>
 #include <boost/geometry/geometries/concepts/check.hpp>
 
 
@@ -38,9 +38,9 @@
 {
 
 
-template <typename Range>
 struct range_count
 {
+ template <typename Range>
     static inline std::size_t apply(Range const& range, bool add_for_open)
     {
         std::size_t n = boost::size(range);
@@ -60,30 +60,31 @@
     }
 };
 
-template <typename Geometry, std::size_t D>
+template <std::size_t D>
 struct other_count
 {
+ template <typename Geometry>
     static inline std::size_t apply(Geometry const&, bool)
     {
         return D;
     }
 };
 
-template <typename Polygon>
-struct polygon_count
+struct polygon_count: private range_count
 {
+ template <typename Polygon>
     static inline std::size_t apply(Polygon const& poly, bool add_for_open)
     {
         typedef typename geometry::ring_type<Polygon>::type ring_type;
 
- std::size_t n = range_count<ring_type>::apply(
+ std::size_t n = range_count::apply(
                     exterior_ring(poly), add_for_open);
 
         typename interior_return_type<Polygon const>::type rings
                     = interior_rings(poly);
         for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
         {
- n += range_count<ring_type>::apply(*it, add_for_open);
+ n += range_count::apply(*it, add_for_open);
         }
 
         return n;
@@ -98,44 +99,42 @@
 namespace dispatch
 {
 
-template <typename GeometryTag, typename Geometry>
-struct num_points
-{
- BOOST_MPL_ASSERT_MSG
- (
- false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
- , (types<Geometry>)
- );
-};
+template
+<
+ typename Geometry,
+ typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type
+>
+struct num_points: not_implemented<Tag>
+{};
 
 template <typename Geometry>
-struct num_points<point_tag, Geometry>
- : detail::num_points::other_count<Geometry, 1>
+struct num_points<Geometry, point_tag>
+ : detail::num_points::other_count<1>
 {};
 
 template <typename Geometry>
-struct num_points<box_tag, Geometry>
- : detail::num_points::other_count<Geometry, 4>
+struct num_points<Geometry, box_tag>
+ : detail::num_points::other_count<4>
 {};
 
 template <typename Geometry>
-struct num_points<segment_tag, Geometry>
- : detail::num_points::other_count<Geometry, 2>
+struct num_points<Geometry, segment_tag>
+ : detail::num_points::other_count<2>
 {};
 
 template <typename Geometry>
-struct num_points<linestring_tag, Geometry>
- : detail::num_points::range_count<Geometry>
+struct num_points<Geometry, linestring_tag>
+ : detail::num_points::range_count
 {};
 
 template <typename Geometry>
-struct num_points<ring_tag, Geometry>
- : detail::num_points::range_count<Geometry>
+struct num_points<Geometry, ring_tag>
+ : detail::num_points::range_count
 {};
 
 template <typename Geometry>
-struct num_points<polygon_tag, Geometry>
- : detail::num_points::polygon_count<Geometry>
+struct num_points<Geometry, polygon_tag>
+ : detail::num_points::polygon_count
 {};
 
 } // namespace dispatch
@@ -158,11 +157,7 @@
 {
     concept::check<Geometry const>();
 
- return dispatch::num_points
- <
- typename tag_cast<typename tag<Geometry>::type, multi_tag>::type,
- Geometry
- >::apply(geometry, add_for_open);
+ return dispatch::num_points<Geometry>::apply(geometry, add_for_open);
 }
 
 }} // namespace boost::geometry

Modified: trunk/boost/geometry/multi/algorithms/num_points.hpp
==============================================================================
--- trunk/boost/geometry/multi/algorithms/num_points.hpp (original)
+++ trunk/boost/geometry/multi/algorithms/num_points.hpp 2012-10-28 15:08:35 EDT (Sun, 28 Oct 2012)
@@ -30,9 +30,9 @@
 {
 
 
-template <typename MultiGeometry>
 struct multi_count
 {
+ template <typename MultiGeometry>
     static inline size_t apply(MultiGeometry const& geometry, bool add_for_open)
     {
         typedef typename boost::range_value<MultiGeometry>::type geometry_type;
@@ -46,11 +46,7 @@
             it != boost::end(geometry);
             ++it)
         {
- n += dispatch::num_points
- <
- typename tag<geometry_type>::type,
- geometry_type
- >::apply(*it, add_for_open);
+ n += dispatch::num_points<geometry_type>::apply(*it, add_for_open);
         }
         return n;
     }
@@ -67,8 +63,8 @@
 
 
 template <typename Geometry>
-struct num_points<multi_tag, Geometry>
- : detail::num_points::multi_count<Geometry> {};
+struct num_points<Geometry, multi_tag>
+ : detail::num_points::multi_count {};
 
 
 } // namespace dispatch


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk