mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-17 13:52:09 +00:00
[strategies][comparable distance (result)] implement comparable distance
result variant support as in all other algorithms
This commit is contained in:
@@ -10,10 +10,20 @@
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_COMPARABLE_DISTANCE_RESULT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_COMPARABLE_DISTANCE_RESULT_HPP
|
||||
|
||||
#include <boost/geometry/strategies/default_comparable_strategy.hpp>
|
||||
#include <boost/mpl/always.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/default_strategy.hpp>
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/distance_result.hpp>
|
||||
|
||||
#include <boost/geometry/util/compress_variant.hpp>
|
||||
#include <boost/geometry/util/transform_variant.hpp>
|
||||
#include <boost/geometry/util/combine_if.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/distance/default_strategies.hpp>
|
||||
|
||||
@@ -21,6 +31,141 @@
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace resolve_strategy
|
||||
{
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
struct comparable_distance_result
|
||||
: strategy::distance::services::return_type
|
||||
<
|
||||
typename strategy::distance::services::comparable_type
|
||||
<
|
||||
Strategy
|
||||
>::type,
|
||||
typename point_type<Geometry1>::type,
|
||||
typename point_type<Geometry2>::type
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct comparable_distance_result<Geometry1, Geometry2, default_strategy>
|
||||
: comparable_distance_result
|
||||
<
|
||||
Geometry1,
|
||||
Geometry2,
|
||||
typename detail::distance::default_strategy
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::type
|
||||
>
|
||||
{};
|
||||
|
||||
} // namespace resolve_strategy
|
||||
|
||||
|
||||
namespace resolve_variant
|
||||
{
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
struct comparable_distance_result
|
||||
: resolve_strategy::comparable_distance_result
|
||||
<
|
||||
Geometry1,
|
||||
Geometry2,
|
||||
Strategy
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry1,
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename T),
|
||||
typename Strategy
|
||||
>
|
||||
struct comparable_distance_result
|
||||
<
|
||||
Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
|
||||
>
|
||||
{
|
||||
// A set of all variant type combinations that are compatible and
|
||||
// implemented
|
||||
typedef typename util::combine_if<
|
||||
typename mpl::vector1<Geometry1>,
|
||||
typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
|
||||
mpl::always<mpl::true_>
|
||||
>::type possible_input_types;
|
||||
|
||||
// The (possibly variant) result type resulting from these combinations
|
||||
typedef typename compress_variant<
|
||||
typename transform_variant<
|
||||
possible_input_types,
|
||||
resolve_strategy::comparable_distance_result<
|
||||
mpl::first<mpl::_>,
|
||||
mpl::second<mpl::_>,
|
||||
Strategy
|
||||
>,
|
||||
mpl::back_inserter<mpl::vector0<> >
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
|
||||
// Distance arguments are commutative
|
||||
template
|
||||
<
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename T),
|
||||
typename Geometry2,
|
||||
typename Strategy
|
||||
>
|
||||
struct comparable_distance_result
|
||||
<
|
||||
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
|
||||
Geometry2,
|
||||
Strategy
|
||||
> : public comparable_distance_result
|
||||
<
|
||||
Geometry2, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Strategy>
|
||||
struct comparable_distance_result
|
||||
<
|
||||
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
|
||||
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
|
||||
Strategy
|
||||
>
|
||||
{
|
||||
// A set of all variant type combinations that are compatible and
|
||||
// implemented
|
||||
typedef typename util::combine_if
|
||||
<
|
||||
typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
|
||||
typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
|
||||
mpl::always<mpl::true_>
|
||||
>::type possible_input_types;
|
||||
|
||||
// The (possibly variant) result type resulting from these combinations
|
||||
typedef typename compress_variant<
|
||||
typename transform_variant<
|
||||
possible_input_types,
|
||||
resolve_strategy::comparable_distance_result<
|
||||
mpl::first<mpl::_>,
|
||||
mpl::second<mpl::_>,
|
||||
Strategy
|
||||
>,
|
||||
mpl::back_inserter<mpl::vector0<> >
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
} // namespace resolve_variant
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\brief Meta-function defining return type of comparable_distance function
|
||||
@@ -33,32 +178,15 @@ template
|
||||
typename Strategy = void
|
||||
>
|
||||
struct comparable_distance_result
|
||||
: distance_result
|
||||
: resolve_variant::comparable_distance_result
|
||||
<
|
||||
Geometry1,
|
||||
Geometry2,
|
||||
typename strategy::distance::services::comparable_type
|
||||
<
|
||||
Strategy
|
||||
>::type
|
||||
Geometry1, Geometry2, Strategy
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct comparable_distance_result<Geometry1, Geometry2, default_strategy>
|
||||
: distance_result<Geometry1, Geometry2, default_comparable_strategy>
|
||||
{};
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct comparable_distance_result
|
||||
<
|
||||
Geometry1, Geometry2, default_comparable_strategy
|
||||
> : distance_result<Geometry1, Geometry2, default_comparable_strategy>
|
||||
{};
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct comparable_distance_result<Geometry1, Geometry2, void>
|
||||
: distance_result<Geometry1, Geometry2, default_comparable_strategy>
|
||||
: comparable_distance_result<Geometry1, Geometry2, default_strategy>
|
||||
{};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user