Boost logo

Boost :

Subject: Re: [boost] A design for geometric objects
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-12-05 20:06:13


Simonson, Lucanus J wrote:

> These operators are overloaded with SFINAE on return type such that three intersection operators are sufficient to cover all valid combinations of any geometry type, rectangle, six flavors of polgyons with and without holes in the manhattan, 45, or general domains, and std containers thereof as well as my data structures that serve as the inputs to the boolean algorithms
>
>
> //manhattan boolean intersection operator
> //works on any two manhattan geometric data types
> template <typename geometry_type_1, typename geometry_type_2>
> typename requires_2<
> typename is_polygon_90_set_type<geometry_type_1>::type::type,
> typename is_polygon_90_set_type<geometry_type_2>::type::type,
> polygon_90_set_view<geometry_type_1, geometry_type_2,
> boolean_op::BinaryAnd> >::type
> operator&(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
> return polygon_90_set_view<geometry_type_1, geometry_type_2,
> boolean_op::BinaryAnd>
> (lvalue, rvalue,
> polygon_90_set_traits<geometry_type_1>::orient(lvalue),
> boolean_op::BinaryAnd());
> }
>
> //45 degree boolean intersection operator
> //works with any combination of 45 and 90
> template <typename geometry_type_1, typename geometry_type_2>
> typename requires_3<
> typename is_polygon_45_or_90_set_type<geometry_type_1>::type::type,
> typename is_polygon_45_or_90_set_type<geometry_type_2>::type::type,
> typename is_either_polygon_45_set_type<geometry_type_1, ``
> geometry_type_2>::type::type,
> polygon_45_set_view<geometry_type_1, geometry_type_2, 1> >::type
> operator&(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
> return polygon_45_set_view<geometry_type_1, geometry_type_2, 1>
> (lvalue, rvalue);
> }
>
> //arbitrary angle boolean intersection operator
> //works with any combination of arbitrary angle, 45 and 90
> template <typename geometry_type_1, typename geometry_type_2>
> typename requires_3<
> typename is_any_polygon_set_type<geometry_type_1>::type::type,
> typename is_any_polygon_set_type<geometry_type_2>::type::type,
> typename is_either_polygon_set_type<geometry_type_1,
> geometry_type_2>::type::type,
> polygon_set_view<geometry_type_1, geometry_type_2, 1> >::type
> operator&(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
> return polygon_set_view<geometry_type_1, geometry_type_2, 1>
> (lvalue, rvalue);
> }
>
>
> Is this what you mean by multiple dispatch, Mathias?

Overloading certainly is ad-hoc polymorphism with multiple-dispatch
based on the static type.
So yes.

However, isn't this ambiguous?
A 90 degree polygon should match all three overloads.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk