From c5b3acb70cf96aab7652e1a25c697ade82b7c51b Mon Sep 17 00:00:00 2001 From: Samuel Debionne Date: Wed, 21 May 2014 21:02:53 +0200 Subject: [PATCH] [expand] Add variant support --- include/boost/geometry/algorithms/expand.hpp | 48 +++++++++++++++++++- test/algorithms/expand.cpp | 1 + 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/algorithms/expand.hpp b/include/boost/geometry/algorithms/expand.hpp index 2e1531bf0..f29fd4a40 100644 --- a/include/boost/geometry/algorithms/expand.hpp +++ b/include/boost/geometry/algorithms/expand.hpp @@ -28,6 +28,9 @@ #include #include +#include +#include + namespace boost { namespace geometry { @@ -249,6 +252,49 @@ struct expand #endif // DOXYGEN_NO_DISPATCH +namespace resolve_variant { + +template +struct expand +{ + template + static inline void apply(Box& box, Geometry const& geometry) + { + concept::check_concepts_and_equal_dimensions(); + + dispatch::expand::apply(box, geometry); + } +}; + +template +struct expand > +{ + template + struct visitor: boost::static_visitor + { + Box& m_box; + + visitor(Box& box) : m_box(box) {} + + template + void operator()(Geometry const& geometry) const + { + return expand::apply(m_box, geometry); + } + }; + + template + static inline void + apply(Box& box, + boost::variant const& geometry) + { + return boost::apply_visitor(visitor(box), geometry); + } +}; + +} // namespace resolve_variant + + /*** *! \brief Expands a box using the extend (envelope) of another geometry (box, point) @@ -292,7 +338,7 @@ inline void expand(Box& box, Geometry const& geometry) { concept::check_concepts_and_equal_dimensions(); - dispatch::expand::apply(box, geometry); + resolve_variant::expand::apply(box, geometry); } }} // namespace boost::geometry diff --git a/test/algorithms/expand.cpp b/test/algorithms/expand.cpp index 213e0b1d9..a1322b87b 100644 --- a/test/algorithms/expand.cpp +++ b/test/algorithms/expand.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)