diff options
Diffstat (limited to 'boost/geometry/algorithms/clear.hpp')
-rw-r--r-- | boost/geometry/algorithms/clear.hpp | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/boost/geometry/algorithms/clear.hpp b/boost/geometry/algorithms/clear.hpp index d7336587ee..1850816b1b 100644 --- a/boost/geometry/algorithms/clear.hpp +++ b/boost/geometry/algorithms/clear.hpp @@ -14,15 +14,19 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP #define BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP -#include <boost/mpl/assert.hpp> + #include <boost/type_traits/remove_const.hpp> +#include <boost/variant/apply_visitor.hpp> +#include <boost/variant/static_visitor.hpp> +#include <boost/variant/variant_fwd.hpp> +#include <boost/geometry/algorithms/not_implemented.hpp> #include <boost/geometry/core/access.hpp> #include <boost/geometry/core/exterior_ring.hpp> #include <boost/geometry/core/interior_rings.hpp> #include <boost/geometry/core/mutable_range.hpp> #include <boost/geometry/core/tag_cast.hpp> - +#include <boost/geometry/core/tags.hpp> #include <boost/geometry/geometries/concepts/check.hpp> @@ -72,6 +76,7 @@ struct no_action } }; + }} // namespace detail::clear #endif // DOXYGEN_NO_DETAIL @@ -84,14 +89,8 @@ template typename Geometry, typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type > -struct clear -{ - BOOST_MPL_ASSERT_MSG - ( - false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE - , (types<Geometry>) - ); -}; +struct clear: not_implemented<Tag> +{}; // Point/box/segment do not have clear. So specialize to do nothing. template <typename Geometry> @@ -127,10 +126,48 @@ struct clear<Polygon, polygon_tag> {}; +template <typename Geometry> +struct clear<Geometry, multi_tag> + : detail::clear::collection_clear<Geometry> +{}; + + } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH +namespace resolve_variant { + +template <typename Geometry> +struct clear +{ + static inline void apply(Geometry& geometry) + { + dispatch::clear<Geometry>::apply(geometry); + } +}; + +template <BOOST_VARIANT_ENUM_PARAMS(typename T)> +struct clear<variant<BOOST_VARIANT_ENUM_PARAMS(T)> > +{ + 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); + } +}; + +} // namespace resolve_variant + + /*! \brief Clears a linestring, ring or polygon (exterior+interiors) or multi* \details Generic function to clear a geometry. All points will be removed from the collection or collections @@ -149,7 +186,7 @@ inline void clear(Geometry& geometry) { concept::check<Geometry>(); - dispatch::clear<Geometry>::apply(geometry); + resolve_variant::clear<Geometry>::apply(geometry); } |