Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/boost/geometry/algorithms/area_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ struct area_result
: detail::area::area_result<Geometry, Strategy>
{};

template <typename ...Ts, typename Strategy>
struct area_result<boost::variant<Ts...>, Strategy>
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Strategy>
struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy>
: geometry::area_result
<
typename util::select_pack_element
<
detail::area::more_precise_coordinate_type,
Ts...
BOOST_VARIANT_ENUM_PARAMS(T)
>::type,
Strategy
>
Expand All @@ -161,14 +161,14 @@ struct area_result<Geometry, default_strategy>
: detail::area::default_area_result<Geometry>
{};

template <typename ...Ts>
struct area_result<boost::variant<Ts...>, default_strategy>
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, default_strategy>
: detail::area::default_area_result
<
typename util::select_pack_element
<
detail::area::more_precise_default_area_result,
Ts...
BOOST_VARIANT_ENUM_PARAMS(T)
>::type
>
{};
Expand Down
15 changes: 15 additions & 0 deletions include/boost/geometry/geometries/point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class point
// passed for non-Cartesian coordinate systems.
enum { cs_check = sizeof(CoordinateSystem) };

template <typename DT, bool Condition, typename T = void>
struct enable_ctor_if
: std::enable_if<Condition, T>
{};

public:

// TODO: constexpr requires LiteralType and until C++20
Expand Down Expand Up @@ -124,6 +129,11 @@ class point
}

/// @brief Constructor to set two values
template
<
typename T = CoordinateType,
typename enable_ctor_if<T, (DimensionCount >= 2), int>::type = 0
>
#if ! defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
constexpr
#endif
Expand All @@ -137,6 +147,11 @@ class point
}

/// @brief Constructor to set three values
template
<
typename T = CoordinateType,
typename enable_ctor_if<T, (DimensionCount >= 3), int>::type = 0
>
#if ! defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
constexpr
#endif
Expand Down
26 changes: 23 additions & 3 deletions include/boost/geometry/geometries/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,30 @@
namespace boost { namespace geometry
{

namespace detail
{

template <typename ...>
struct parameter_pack_first_type {};

template <typename T, typename ... Ts>
struct parameter_pack_first_type<T, Ts...>
{
typedef T type;
};

} // namespace detail


template <typename T, typename ...Ts>
struct point_type<boost::variant<T, Ts...> >
: point_type<T>
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct point_type<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
: point_type
<
typename detail::parameter_pack_first_type
<
BOOST_VARIANT_ENUM_PARAMS(T)
>::type
>
{};


Expand Down
6 changes: 3 additions & 3 deletions include/boost/geometry/srs/projections/dpar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ template <typename Variant, typename T>
struct find_type_index
{};

template <typename ...Types, typename T>
struct find_type_index<boost::variant<Types...>, T>
: find_type_index_impl<T, 0, Types...>
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename T>
struct find_type_index<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, T>
: find_type_index_impl<T, 0, BOOST_VARIANT_ENUM_PARAMS(T)>
{};


Expand Down
43 changes: 33 additions & 10 deletions include/boost/geometry/strategies/comparable_distance_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ struct comparable_distance_result
{};


template <typename Geometry1, typename ...Ts, typename Strategy>
struct comparable_distance_result<Geometry1, boost::variant<Ts...>, 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
>
{
// Select the most precise distance strategy result type
// for all variant type combinations.
Expand All @@ -142,7 +150,7 @@ struct comparable_distance_result<Geometry1, boost::variant<Ts...>, Strategy>
typedef typename util::select_combination_element
<
util::type_sequence<Geometry1>,
util::type_sequence<Ts...>,
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>,
detail::distance::more_precise_comparable_distance_result
<
Strategy
Expand All @@ -159,19 +167,34 @@ struct comparable_distance_result<Geometry1, boost::variant<Ts...>, Strategy>


// Distance arguments are commutative
template <typename ...Ts, typename Geometry2, typename Strategy>
struct comparable_distance_result<boost::variant<Ts...>, Geometry2, Strategy>
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<Ts...>, Strategy
Geometry2, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
>
{};


template <typename ...Ts, typename ...Us, typename Strategy>
template
<
BOOST_VARIANT_ENUM_PARAMS(typename T),
BOOST_VARIANT_ENUM_PARAMS(typename U),
typename Strategy
>
struct comparable_distance_result
<
boost::variant<Ts...>, boost::variant<Us...>, Strategy
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(U)>,
Strategy
>
{
// Select the most precise distance strategy result type
Expand All @@ -180,8 +203,8 @@ struct comparable_distance_result
// but is_implemented is not ready for prime time.
typedef typename util::select_combination_element
<
util::type_sequence<Ts...>,
util::type_sequence<Us...>,
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>,
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(U)>,
detail::distance::more_precise_comparable_distance_result
<
Strategy
Expand Down
6 changes: 3 additions & 3 deletions include/boost/geometry/strategies/default_length_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ struct default_length_result
: resolve_strategy::default_length_result<Geometry>
{};

template <typename ...Ts>
struct default_length_result<boost::variant<Ts...> >
: resolve_strategy::default_length_result<Ts...>
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct default_length_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
: resolve_strategy::default_length_result<BOOST_VARIANT_ENUM_PARAMS(T)>
{};

} // namespace resolve_variant
Expand Down
49 changes: 39 additions & 10 deletions include/boost/geometry/strategies/distance_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,16 @@ struct distance_result
{};


template <typename Geometry1, typename ...Ts, typename Strategy>
struct distance_result<Geometry1, boost::variant<Ts...>, Strategy>
template
<
typename Geometry1,
BOOST_VARIANT_ENUM_PARAMS(typename T),
typename Strategy
>
struct distance_result
<
Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
>
{
// Select the most precise distance strategy result type
// for all variant type combinations.
Expand All @@ -150,7 +158,7 @@ struct distance_result<Geometry1, boost::variant<Ts...>, Strategy>
typedef typename util::select_combination_element
<
util::type_sequence<Geometry1>,
util::type_sequence<Ts...>,
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>,
detail::distance::more_precise_distance_result<Strategy>::template predicate
>::type elements;

Expand All @@ -164,23 +172,44 @@ struct distance_result<Geometry1, boost::variant<Ts...>, Strategy>


// Distance arguments are commutative
template <typename ...Ts, typename Geometry2, typename Strategy>
struct distance_result<boost::variant<Ts...>, Geometry2, Strategy>
: public distance_result<Geometry2, boost::variant<Ts...>, Strategy>
template
<
BOOST_VARIANT_ENUM_PARAMS(typename T),
typename Geometry2,
typename Strategy
>
struct distance_result
<
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2, Strategy
>
: public distance_result
<
Geometry2, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
>
{};


template <typename ...Ts, typename ...Us, typename Strategy>
struct distance_result<boost::variant<Ts...>, boost::variant<Us...>, Strategy>
template
<
BOOST_VARIANT_ENUM_PARAMS(typename T),
BOOST_VARIANT_ENUM_PARAMS(typename U),
typename Strategy
>
struct distance_result
<
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(U)>,
Strategy
>
{
// Select the most precise distance strategy result type
// for all variant type combinations.
// TODO: We should ignore the combinations that are not valid
// but is_implemented is not ready for prime time.
typedef typename util::select_combination_element
<
util::type_sequence<Ts...>,
util::type_sequence<Us...>,
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>,
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(U)>,
detail::distance::more_precise_distance_result<Strategy>::template predicate
>::type elements;

Expand Down