Reduced dispatch::convert required parameters to their bare minimum.

[SVN r75948]
This commit is contained in:
Bruno Lalande
2011-12-14 23:29:35 +00:00
parent cdaba1bebb
commit d7e613f8b7
4 changed files with 31 additions and 48 deletions

View File

@@ -47,17 +47,11 @@ struct check_distance
{};
template <typename G1, typename G2>
struct check_convert
: boost::geometry::dispatch::convert<
typename boost::geometry::tag_cast<typename boost::geometry::tag<G1>::type, boost::geometry::multi_tag>::type,
typename boost::geometry::tag_cast<typename boost::geometry::tag<G2>::type, boost::geometry::multi_tag>::type,
G1,
G2
>
struct check_convert: boost::geometry::dispatch::convert<G1, G2>
{};
template <class T1>
template <typename T1>
struct distance_tester
{
template <typename T2>
@@ -90,7 +84,7 @@ struct distance_tester<void>
};
template <class T1>
template <typename T1>
struct convert_tester
{
template <typename T2>

View File

@@ -163,13 +163,7 @@ inline void assign(Geometry1& geometry1, Geometry2 const& geometry2)
, (types<Geometry1, Geometry2>)
);
dispatch::convert
<
typename tag<Geometry2>::type,
typename tag<Geometry1>::type,
Geometry2,
Geometry1
>::apply(geometry2, geometry1);
dispatch::convert<Geometry2, Geometry1>::apply(geometry2, geometry1);
}

View File

@@ -214,8 +214,9 @@ namespace dispatch
template
<
typename Tag1, typename Tag2,
typename Geometry1, typename Geometry2,
typename Tag1 = typename tag_cast<typename tag<Geometry1>::type, multi_tag>::type,
typename Tag2 = typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type,
std::size_t DimensionCount = dimension<Geometry1>::type::value,
bool UseAssignment = boost::is_same<Geometry1, Geometry2>::value
&& !boost::is_array<Geometry1>::value
@@ -228,11 +229,11 @@ struct convert: boost::geometry::not_implemented<for_geometry<Tag1>,
template
<
typename Tag,
typename Geometry1, typename Geometry2,
typename Tag,
std::size_t DimensionCount
>
struct convert<Tag, Tag, Geometry1, Geometry2, DimensionCount, true>
struct convert<Geometry1, Geometry2, Tag, Tag, DimensionCount, true>
{
// Same geometry type -> copy whole geometry
static inline void apply(Geometry1 const& source, Geometry2& destination)
@@ -247,7 +248,7 @@ template
typename Geometry1, typename Geometry2,
std::size_t DimensionCount
>
struct convert<point_tag, point_tag, Geometry1, Geometry2, DimensionCount, false>
struct convert<Geometry1, Geometry2, point_tag, point_tag, DimensionCount, false>
: detail::conversion::point_to_point<Geometry1, Geometry2, 0, DimensionCount>
{};
@@ -257,7 +258,7 @@ template
typename Box1, typename Box2,
std::size_t DimensionCount
>
struct convert<box_tag, box_tag, Box1, Box2, DimensionCount, false>
struct convert<Box1, Box2, box_tag, box_tag, DimensionCount, false>
: detail::conversion::indexed_to_indexed<Box1, Box2, 0, DimensionCount>
{};
@@ -267,19 +268,19 @@ template
typename Segment1, typename Segment2,
std::size_t DimensionCount
>
struct convert<segment_tag, segment_tag, Segment1, Segment2, DimensionCount, false>
struct convert<Segment1, Segment2, segment_tag, segment_tag, DimensionCount, false>
: detail::conversion::indexed_to_indexed<Segment1, Segment2, 0, DimensionCount>
{};
template <typename Segment, typename LineString, std::size_t DimensionCount>
struct convert<segment_tag, linestring_tag, Segment, LineString, DimensionCount, false>
struct convert<Segment, LineString, segment_tag, linestring_tag, DimensionCount, false>
: detail::conversion::segment_to_range<Segment, LineString>
{};
template <typename Ring1, typename Ring2, std::size_t DimensionCount>
struct convert<ring_tag, ring_tag, Ring1, Ring2, DimensionCount, false>
struct convert<Ring1, Ring2, ring_tag, ring_tag, DimensionCount, false>
: detail::conversion::range_to_range
<
Ring1,
@@ -290,17 +291,17 @@ struct convert<ring_tag, ring_tag, Ring1, Ring2, DimensionCount, false>
{};
template <typename LineString1, typename LineString2, std::size_t DimensionCount>
struct convert<linestring_tag, linestring_tag, LineString1, LineString2, DimensionCount, false>
struct convert<LineString1, LineString2, linestring_tag, linestring_tag, DimensionCount, false>
: detail::conversion::range_to_range<LineString1, LineString2>
{};
template <typename Polygon1, typename Polygon2, std::size_t DimensionCount>
struct convert<polygon_tag, polygon_tag, Polygon1, Polygon2, DimensionCount, false>
struct convert<Polygon1, Polygon2, polygon_tag, polygon_tag, DimensionCount, false>
: detail::conversion::polygon_to_polygon<Polygon1, Polygon2>
{};
template <typename Box, typename Ring>
struct convert<box_tag, ring_tag, Box, Ring, 2, false>
struct convert<Box, Ring, box_tag, ring_tag, 2, false>
: detail::conversion::box_to_range
<
Box,
@@ -312,7 +313,7 @@ struct convert<box_tag, ring_tag, Box, Ring, 2, false>
template <typename Box, typename Polygon>
struct convert<box_tag, polygon_tag, Box, Polygon, 2, false>
struct convert<Box, Polygon, box_tag, polygon_tag, 2, false>
{
static inline void apply(Box const& box, Polygon& polygon)
{
@@ -320,8 +321,8 @@ struct convert<box_tag, polygon_tag, Box, Polygon, 2, false>
convert
<
box_tag, ring_tag,
Box, ring_type,
box_tag, ring_tag,
2, false
>::apply(box, exterior_ring(polygon));
}
@@ -329,7 +330,7 @@ struct convert<box_tag, polygon_tag, Box, Polygon, 2, false>
template <typename Point, typename Box, std::size_t DimensionCount>
struct convert<point_tag, box_tag, Point, Box, DimensionCount, false>
struct convert<Point, Box, point_tag, box_tag, DimensionCount, false>
{
static inline void apply(Point const& point, Box& box)
{
@@ -346,15 +347,15 @@ struct convert<point_tag, box_tag, Point, Box, DimensionCount, false>
template <typename Ring, typename Polygon, std::size_t DimensionCount>
struct convert<ring_tag, polygon_tag, Ring, Polygon, DimensionCount, false>
struct convert<Ring, Polygon, ring_tag, polygon_tag, DimensionCount, false>
{
static inline void apply(Ring const& ring, Polygon& polygon)
{
typedef typename ring_type<Polygon>::type ring_type;
convert
<
ring_tag, ring_tag,
Ring, ring_type,
ring_tag, ring_tag,
DimensionCount, false
>::apply(ring, exterior_ring(polygon));
}
@@ -362,7 +363,7 @@ struct convert<ring_tag, polygon_tag, Ring, Polygon, DimensionCount, false>
template <typename Polygon, typename Ring, std::size_t DimensionCount>
struct convert<polygon_tag, ring_tag, Polygon, Ring, DimensionCount, false>
struct convert<Polygon, Ring, polygon_tag, ring_tag, DimensionCount, false>
{
static inline void apply(Polygon const& polygon, Ring& ring)
{
@@ -370,8 +371,8 @@ struct convert<polygon_tag, ring_tag, Polygon, Ring, DimensionCount, false>
convert
<
ring_tag, ring_tag,
ring_type, Ring,
ring_tag, ring_tag,
DimensionCount, false
>::apply(exterior_ring(polygon), ring);
}
@@ -402,13 +403,7 @@ inline void convert(Geometry1 const& geometry1, Geometry2& geometry2)
{
concept::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2>();
dispatch::convert
<
typename tag_cast<typename tag<Geometry1>::type, multi_tag>::type,
typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type,
Geometry1,
Geometry2
>::apply(geometry1, geometry2);
dispatch::convert<Geometry1, Geometry2>::apply(geometry1, geometry2);
}

View File

@@ -74,13 +74,15 @@ namespace dispatch
// version types might be the same and therefore we call boost::is_same again
template <typename Multi1, typename Multi2, std::size_t DimensionCount>
struct convert<multi_tag, multi_tag, Multi1, Multi2, DimensionCount, false>
struct convert<Multi1, Multi2, multi_tag, multi_tag, DimensionCount, false>
: detail::conversion::multi_to_multi
<
Multi1,
Multi2,
convert
<
typename boost::range_value<Multi1>::type,
typename boost::range_value<Multi2>::type,
typename single_tag_of
<
typename tag<Multi1>::type
@@ -89,28 +91,26 @@ struct convert<multi_tag, multi_tag, Multi1, Multi2, DimensionCount, false>
<
typename tag<Multi2>::type
>::type,
typename boost::range_value<Multi1>::type,
typename boost::range_value<Multi2>::type,
DimensionCount
>
>
{};
template <typename SingleTag, typename Single, typename Multi, std::size_t DimensionCount>
struct convert<SingleTag, multi_tag, Single, Multi, DimensionCount, false>
template <typename Single, typename Multi, typename SingleTag, std::size_t DimensionCount>
struct convert<Single, Multi, SingleTag, multi_tag, DimensionCount, false>
: detail::conversion::single_to_multi
<
Single,
Multi,
convert
<
Single,
typename boost::range_value<Multi>::type,
typename tag<Single>::type,
typename single_tag_of
<
typename tag<Multi>::type
>::type,
Single,
typename boost::range_value<Multi>::type,
DimensionCount,
false
>