Skip to content

Commit

Permalink
Merge pull request #1255 from awulkiew/feature/type_aliases
Browse files Browse the repository at this point in the history
Add alias templates for core and util traits
  • Loading branch information
awulkiew committed May 11, 2024
2 parents 1f8b6e0 + 51cf51a commit a7644cb
Show file tree
Hide file tree
Showing 26 changed files with 451 additions and 319 deletions.
19 changes: 9 additions & 10 deletions include/boost/geometry/algorithms/append.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2024 Adam Wulkiewicz, Lodz, Poland.

// This file was modified by Oracle on 2014-2023.
// Modifications copyright (c) 2014-2023, Oracle and/or its affiliates.
Expand Down Expand Up @@ -60,7 +61,7 @@ struct to_range_point
static inline void apply(Geometry& geometry, Point const& point,
signed_size_type = -1, signed_size_type = 0)
{
typename geometry::point_type<Geometry>::type copy;
geometry::point_type_t<Geometry> copy;
geometry::detail::conversion::convert_point_to_point(point, copy);
traits::push_back<Geometry>::apply(geometry, copy);
}
Expand Down Expand Up @@ -90,7 +91,7 @@ struct to_polygon_point
static inline void apply(Polygon& polygon, Point const& point,
signed_size_type ring_index, signed_size_type = 0)
{
using ring_type = typename ring_type<Polygon>::type;
using ring_type = ring_type_t<Polygon>;

if (ring_index == -1)
{
Expand All @@ -112,18 +113,16 @@ struct to_polygon_range
static inline void apply(Polygon& polygon, Range const& range,
signed_size_type ring_index, signed_size_type = 0)
{
using ring_type = typename ring_type<Polygon>::type;
using exterior_ring_type = typename ring_return_type<Polygon>::type;
using interior_ring_range_type = typename interior_return_type<Polygon>::type;

using ring_type = ring_type_t<Polygon>;

if (ring_index == -1)
{
exterior_ring_type ext_ring = exterior_ring(polygon);
auto&& ext_ring = exterior_ring(polygon);
to_range_range::apply<ring_type, Range>(ext_ring, range);
}
else if (ring_index < signed_size_type(num_interior_rings(polygon)))
{
interior_ring_range_type int_rings = interior_rings(polygon);
auto&& int_rings = interior_rings(polygon);
to_range_range::apply<ring_type, Range>(range::at(int_rings, ring_index), range);
}
}
Expand Down Expand Up @@ -159,8 +158,8 @@ template
<
typename Geometry,
typename RangeOrPoint,
typename Tag = typename geometry::tag<Geometry>::type,
typename OtherTag = typename geometry::tag<RangeOrPoint>::type
typename Tag = geometry::tag_t<Geometry>,
typename OtherTag = geometry::tag_t<RangeOrPoint>
>
struct append
: detail::append::append_no_action
Expand Down
36 changes: 13 additions & 23 deletions include/boost/geometry/algorithms/area.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2017-2022 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2017-2024 Adam Wulkiewicz, Lodz, Poland.

// This file was modified by Oracle on 2017-2023.
// Modifications copyright (c) 2017-2023 Oracle and/or its affiliates.
Expand Down Expand Up @@ -131,13 +131,12 @@ namespace dispatch
template
<
typename Geometry,
typename Tag = typename tag<Geometry>::type
typename Tag = tag_t<Geometry>
>
struct area : detail::calculate_null
{
template <typename Strategy>
static inline typename area_result<Geometry, Strategy>::type
apply(Geometry const& geometry, Strategy const& strategy)
static inline auto apply(Geometry const& geometry, Strategy const& strategy)
{
return calculate_null::apply
<
Expand All @@ -162,8 +161,7 @@ template <typename Polygon>
struct area<Polygon, polygon_tag> : detail::calculate_polygon_sum
{
template <typename Strategy>
static inline typename area_result<Polygon, Strategy>::type
apply(Polygon const& polygon, Strategy const& strategy)
static inline auto apply(Polygon const& polygon, Strategy const& strategy)
{
return calculate_polygon_sum::apply
<
Expand All @@ -178,8 +176,7 @@ template <typename MultiGeometry>
struct area<MultiGeometry, multi_polygon_tag> : detail::multi_sum
{
template <typename Strategy>
static inline typename area_result<MultiGeometry, Strategy>::type
apply(MultiGeometry const& multi, Strategy const& strategy)
static inline auto apply(MultiGeometry const& multi, Strategy const& strategy)
{
return multi_sum::apply
<
Expand All @@ -205,8 +202,7 @@ template
struct area
{
template <typename Geometry>
static inline typename area_result<Geometry, Strategy>::type
apply(Geometry const& geometry, Strategy const& strategy)
static inline auto apply(Geometry const& geometry, Strategy const& strategy)
{
return dispatch::area<Geometry>::apply(geometry, strategy);
}
Expand All @@ -230,8 +226,7 @@ template <>
struct area<default_strategy, false>
{
template <typename Geometry>
static inline typename area_result<Geometry>::type
apply(Geometry const& geometry, default_strategy)
static inline auto apply(Geometry const& geometry, default_strategy)
{
typedef typename strategies::area::services::default_strategy
<
Expand All @@ -249,12 +244,11 @@ struct area<default_strategy, false>
namespace resolve_dynamic
{

template <typename Geometry, typename Tag = typename geometry::tag<Geometry>::type>
template <typename Geometry, typename Tag = geometry::tag_t<Geometry>>
struct area
{
template <typename Strategy>
static inline typename area_result<Geometry, Strategy>::type
apply(Geometry const& geometry, Strategy const& strategy)
static inline auto apply(Geometry const& geometry, Strategy const& strategy)
{
return resolve_strategy::area<Strategy>::apply(geometry, strategy);
}
Expand All @@ -264,8 +258,7 @@ template <typename Geometry>
struct area<Geometry, dynamic_geometry_tag>
{
template <typename Strategy>
static inline typename area_result<Geometry, Strategy>::type
apply(Geometry const& geometry, Strategy const& strategy)
static inline auto apply(Geometry const& geometry, Strategy const& strategy)
{
typename area_result<Geometry, Strategy>::type result = 0;
traits::visit<Geometry>::apply([&](auto const& g)
Expand All @@ -280,8 +273,7 @@ template <typename Geometry>
struct area<Geometry, geometry_collection_tag>
{
template <typename Strategy>
static inline typename area_result<Geometry, Strategy>::type
apply(Geometry const& geometry, Strategy const& strategy)
static inline auto apply(Geometry const& geometry, Strategy const& strategy)
{
typename area_result<Geometry, Strategy>::type result = 0;
detail::visit_breadth_first([&](auto const& g)
Expand Down Expand Up @@ -318,8 +310,7 @@ and Geographic as well.
\qbk{[area] [area_output]}
*/
template <typename Geometry>
inline typename area_result<Geometry>::type
area(Geometry const& geometry)
inline auto area(Geometry const& geometry)
{
concepts::check<Geometry const>();

Expand Down Expand Up @@ -354,8 +345,7 @@ area(Geometry const& geometry)
}
*/
template <typename Geometry, typename Strategy>
inline typename area_result<Geometry, Strategy>::type
area(Geometry const& geometry, Strategy const& strategy)
inline auto area(Geometry const& geometry, Strategy const& strategy)
{
concepts::check<Geometry const>();

Expand Down
17 changes: 9 additions & 8 deletions include/boost/geometry/algorithms/assign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2014 Samuel Debionne, Grenoble, France.
// Copyright (c) 2024 Adam Wulkiewicz, Lodz, Poland.

// This file was modified by Oracle on 2020-2023.
// Modifications copyright (c) 2020-2023 Oracle and/or its affiliates.
Expand Down Expand Up @@ -91,7 +92,7 @@ inline void assign_inverse(Geometry& geometry)

dispatch::assign_inverse
<
typename tag<Geometry>::type,
tag_t<Geometry>,
Geometry
>::apply(geometry);
}
Expand All @@ -111,7 +112,7 @@ inline void assign_zero(Geometry& geometry)

dispatch::assign_zero
<
typename tag<Geometry>::type,
tag_t<Geometry>,
Geometry
>::apply(geometry);
}
Expand Down Expand Up @@ -141,9 +142,9 @@ inline void assign_values(Geometry& geometry, Type const& c1, Type const& c2)

dispatch::assign
<
typename tag<Geometry>::type,
tag_t<Geometry>,
Geometry,
geometry::dimension<Geometry>::type::value
geometry::dimension<Geometry>::value
>::apply(geometry, c1, c2);
}

Expand Down Expand Up @@ -174,9 +175,9 @@ inline void assign_values(Geometry& geometry,

dispatch::assign
<
typename tag<Geometry>::type,
tag_t<Geometry>,
Geometry,
geometry::dimension<Geometry>::type::value
geometry::dimension<Geometry>::value
>::apply(geometry, c1, c2, c3);
}

Expand All @@ -201,9 +202,9 @@ inline void assign_values(Geometry& geometry,

dispatch::assign
<
typename tag<Geometry>::type,
tag_t<Geometry>,
Geometry,
geometry::dimension<Geometry>::type::value
geometry::dimension<Geometry>::value
>::apply(geometry, c1, c2, c3, c4);
}

Expand Down
18 changes: 9 additions & 9 deletions include/boost/geometry/algorithms/centroid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2014-2024 Adam Wulkiewicz, Lodz, Poland.

// This file was modified by Oracle on 2014-2023.
// Modifications copyright (c) 2014-2023 Oracle and/or its affiliates.
Expand Down Expand Up @@ -184,7 +184,7 @@ struct centroid_range_state
typename PointTransformer::result_type
pt = transformer.apply(*it);

using point_type = typename geometry::point_type<Ring const>::type;
using point_type = geometry::point_type_t<Ring const>;
strategy.apply(static_cast<point_type const&>(previous_pt),
static_cast<point_type const&>(pt),
state);
Expand All @@ -208,7 +208,7 @@ struct centroid_range

typename Strategy::template state_type
<
typename geometry::point_type<Range>::type,
geometry::point_type_t<Range>,
Point
>::type state;

Expand Down Expand Up @@ -265,7 +265,7 @@ struct centroid_polygon

typename Strategy::template state_type
<
typename geometry::point_type<Polygon>::type,
geometry::point_type_t<Polygon>,
Point
>::type state;

Expand Down Expand Up @@ -333,7 +333,7 @@ struct centroid_multi

typename Strategy::template state_type
<
typename geometry::point_type<Multi>::type,
geometry::point_type_t<Multi>,
Point
>::type state;

Expand Down Expand Up @@ -393,7 +393,7 @@ namespace dispatch
template
<
typename Geometry,
typename Tag = typename tag<Geometry>::type
typename Tag = tag_t<Geometry>
>
struct centroid: not_implemented<Tag>
{};
Expand Down Expand Up @@ -511,10 +511,10 @@ struct centroid<default_strategy, false>
template <typename Geometry, typename Point>
static inline void apply(Geometry const& geometry, Point& out, default_strategy)
{
typedef typename strategies::centroid::services::default_strategy
using strategies_type = typename strategies::centroid::services::default_strategy
<
Geometry
>::type strategies_type;
>::type;

dispatch::centroid<Geometry>::apply(geometry, out, strategies_type());
}
Expand All @@ -525,7 +525,7 @@ struct centroid<default_strategy, false>

namespace resolve_dynamic {

template <typename Geometry, typename Tag = typename tag<Geometry>::type>
template <typename Geometry, typename Tag = tag_t<Geometry>>
struct centroid
{
template <typename Point, typename Strategy>
Expand Down
11 changes: 6 additions & 5 deletions include/boost/geometry/algorithms/clear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2024 Adam Wulkiewicz, Lodz, Poland.

// This file was modified by Oracle on 2020-2023.
// Modifications copyright (c) 2020-2023, Oracle and/or its affiliates.
Expand Down Expand Up @@ -56,17 +57,17 @@ struct polygon_clear
{
traits::clear
<
typename std::remove_reference
std::remove_reference_t
<
typename traits::interior_mutable_type<Polygon>::type
>::type
>
>::apply(interior_rings(polygon));
traits::clear
<
typename std::remove_reference
std::remove_reference_t
<
typename traits::ring_mutable_type<Polygon>::type
>::type
>
>::apply(exterior_ring(polygon));
}
};
Expand All @@ -90,7 +91,7 @@ namespace dispatch
template
<
typename Geometry,
typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type
typename Tag = tag_cast_t<tag_t<Geometry>, multi_tag>
>
struct clear: not_implemented<Tag>
{};
Expand Down
Loading

0 comments on commit a7644cb

Please sign in to comment.