|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82470 - trunk/boost/geometry/algorithms
From: bruno.lalande_at_[hidden]
Date: 2013-01-12 16:28:59
Author: bruno.lalande
Date: 2013-01-12 16:28:59 EST (Sat, 12 Jan 2013)
New Revision: 82470
URL: http://svn.boost.org/trac/boost/changeset/82470
Log:
Reimplemented variants handling in num_points algorithm.
Text files modified:
trunk/boost/geometry/algorithms/num_points.hpp | 63 +++++++++++++++++++++++----------------
1 files changed, 37 insertions(+), 26 deletions(-)
Modified: trunk/boost/geometry/algorithms/num_points.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/num_points.hpp (original)
+++ trunk/boost/geometry/algorithms/num_points.hpp 2013-01-12 16:28:59 EST (Sat, 12 Jan 2013)
@@ -27,9 +27,9 @@
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
-#include <boost/geometry/geometries/variant.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
+#include <boost/variant/variant_fwd.hpp>
namespace boost { namespace geometry
@@ -109,30 +109,6 @@
struct num_points: not_implemented<Tag>
{};
-template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Unused>
-struct num_points<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Unused>
-{
- struct visitor: boost::static_visitor<std::size_t>
- {
- bool m_add_for_open;
-
- visitor(bool add_for_open): m_add_for_open(add_for_open) {}
-
- template <typename Geometry>
- typename std::size_t operator()(Geometry const& geometry) const
- {
- return dispatch::num_points<Geometry>::apply(geometry, m_add_for_open);
- }
- };
-
- template <typename Variant>
- static inline std::size_t
- apply(Variant const& variant_geometry, bool add_for_open)
- {
- return boost::apply_visitor(visitor(add_for_open), variant_geometry);
- }
-};
-
template <typename Geometry>
struct num_points<Geometry, point_tag>
: detail::num_points::other_count<1>
@@ -163,6 +139,41 @@
: detail::num_points::polygon_count
{};
+template <typename Geometry>
+struct devarianted_num_points
+{
+ static inline std::size_t apply(Geometry const& geometry,
+ bool add_for_open)
+ {
+ return num_points<Geometry>::apply(geometry, add_for_open);
+ }
+};
+
+template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
+struct devarianted_num_points<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
+{
+ struct visitor: boost::static_visitor<std::size_t>
+ {
+ bool m_add_for_open;
+
+ visitor(bool add_for_open): m_add_for_open(add_for_open) {}
+
+ template <typename Geometry>
+ typename std::size_t operator()(Geometry const& geometry) const
+ {
+ return dispatch::num_points<Geometry>::apply(geometry, m_add_for_open);
+ }
+ };
+
+ static inline std::size_t
+ apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
+ bool add_for_open)
+ {
+ return boost::apply_visitor(visitor(add_for_open), geometry);
+ }
+};
+
+
} // namespace dispatch
#endif
@@ -183,7 +194,7 @@
{
concept::check<Geometry const>();
- return dispatch::num_points<Geometry>::apply(geometry, add_for_open);
+ return dispatch::devarianted_num_points<Geometry>::apply(geometry, add_for_open);
}
}} // namespace boost::geometry
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