Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82450 - trunk/boost/geometry/algorithms
From: bruno.lalande_at_[hidden]
Date: 2013-01-11 16:54:41


Author: bruno.lalande
Date: 2013-01-11 16:54:41 EST (Fri, 11 Jan 2013)
New Revision: 82450
URL: http://svn.boost.org/trac/boost/changeset/82450

Log:
Reimplemented variants handling in clear() to avoid function overloading.
Text files modified:
   trunk/boost/geometry/algorithms/clear.hpp | 43 ++++++++++++++++-----------------------
   1 files changed, 18 insertions(+), 25 deletions(-)

Modified: trunk/boost/geometry/algorithms/clear.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/clear.hpp (original)
+++ trunk/boost/geometry/algorithms/clear.hpp 2013-01-11 16:54:41 EST (Fri, 11 Jan 2013)
@@ -90,6 +90,24 @@
 struct clear: not_implemented<Tag>
 {};
 
+template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
+struct clear<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, void>
+{
+ struct visitor: static_visitor<void>
+ {
+ template <typename Geometry>
+ inline void operator()(Geometry& geometry) const
+ {
+ clear<Geometry>::apply(geometry);
+ }
+ };
+
+ static inline void apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry)
+ {
+ apply_visitor(visitor(), geometry);
+ }
+};
+
 // Point/box/segment do not have clear. So specialize to do nothing.
 template <typename Geometry>
 struct clear<Geometry, point_tag>
@@ -117,24 +135,6 @@
 {};
 
 
-// Polygon can (indirectly) use std for clear
-template <typename Polygon>
-struct clear<Polygon, polygon_tag>
- : detail::clear::polygon_clear<Polygon>
-{};
-
-
-struct clear_variant_dispatcher: boost::static_visitor<void>
-{
- template <typename Geometry>
- void operator()(Geometry& geometry) const
- {
- concept::check<Geometry>();
- clear<Geometry>::apply(geometry);
- }
-};
-
-
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH
 
@@ -161,13 +161,6 @@
 }
 
 
-template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
-inline void clear(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry)
-{
- apply_visitor(dispatch::clear_variant_dispatcher(), geometry);
-}
-
-
 }} // 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