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)