mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-09 23:22:10 +00:00
[algorithms][is_simple] add variant support
This commit is contained in:
@@ -10,6 +10,10 @@
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_IS_SIMPLE_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_IS_SIMPLE_HPP
|
||||
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/is_simple/always_simple.hpp>
|
||||
#include <boost/geometry/algorithms/detail/is_simple/areal.hpp>
|
||||
#include <boost/geometry/algorithms/detail/is_simple/linear.hpp>
|
||||
@@ -22,10 +26,45 @@ namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace resolve_variant {
|
||||
|
||||
template <typename Geometry>
|
||||
struct is_simple
|
||||
{
|
||||
static inline bool apply(Geometry const& geometry)
|
||||
{
|
||||
concept::check<Geometry const>();
|
||||
return dispatch::is_simple<Geometry>::apply(geometry);
|
||||
}
|
||||
};
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
||||
struct is_simple<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
||||
{
|
||||
struct visitor : boost::static_visitor<bool>
|
||||
{
|
||||
template <typename Geometry>
|
||||
bool operator()(Geometry const& geometry) const
|
||||
{
|
||||
return is_simple<Geometry>::apply(geometry);
|
||||
}
|
||||
};
|
||||
|
||||
static inline bool
|
||||
apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
|
||||
{
|
||||
return boost::apply_visitor(visitor(), geometry);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace resolve_variant
|
||||
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
inline bool is_simple(Geometry const& g)
|
||||
{
|
||||
return dispatch::is_simple<Geometry>::apply(g);
|
||||
return resolve_variant::is_simple<Geometry>::apply(g);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user