Skip to content

Commit f8972d5

Browse files
Use std::ranges::subrange instead of boost::iterator_range (#7001)
* Use std::ranges::subrange instead of boost::iterator_range * Use std::ranges::subrange instead of boost::iterator_range * Use std::ranges::subrange instead of boost::iterator_range * Use std::ranges::subrange instead of boost::iterator_range * Use std::ranges::subrange instead of boost::iterator_range * Use std::ranges::subrange instead of boost::iterator_range --------- Co-authored-by: Dennis Luxen <[email protected]>
1 parent 8ffbc44 commit f8972d5

31 files changed

+123
-210
lines changed

include/customizer/cell_customizer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ class CellCustomizer
100100
distances.front() =
101101
inserted ? heap.GetData(destination).distance : INVALID_EDGE_DISTANCE;
102102

103-
weights.advance_begin(1);
104-
durations.advance_begin(1);
105-
distances.advance_begin(1);
103+
weights.advance(1);
104+
durations.advance(1);
105+
distances.advance(1);
106106
}
107107
BOOST_ASSERT(weights.empty());
108108
BOOST_ASSERT(durations.empty());

include/engine/api/nearest_api.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class NearestAPI final : public BaseAPI
136136
forward_geometry = facade.GetUncompressedForwardGeometry(geometry_id);
137137

138138
auto osm_node_id =
139-
facade.GetOSMNodeIDOfNode(forward_geometry(phantom_node.fwd_segment_position));
139+
facade.GetOSMNodeIDOfNode(forward_geometry[phantom_node.fwd_segment_position]);
140140
to_node = static_cast<std::uint64_t>(osm_node_id);
141141
}
142142

@@ -146,14 +146,14 @@ class NearestAPI final : public BaseAPI
146146
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
147147
const auto geometry = facade.GetUncompressedForwardGeometry(geometry_id);
148148
auto osm_node_id =
149-
facade.GetOSMNodeIDOfNode(geometry(phantom_node.fwd_segment_position + 1));
149+
facade.GetOSMNodeIDOfNode(geometry[phantom_node.fwd_segment_position + 1]);
150150
from_node = static_cast<std::uint64_t>(osm_node_id);
151151
}
152152
else if (phantom_node.forward_segment_id.enabled && phantom_node.fwd_segment_position > 0)
153153
{
154154
// In the case of one way, rely on forward segment only
155155
auto osm_node_id =
156-
facade.GetOSMNodeIDOfNode(forward_geometry(phantom_node.fwd_segment_position - 1));
156+
facade.GetOSMNodeIDOfNode(forward_geometry[phantom_node.fwd_segment_position - 1]);
157157
from_node = static_cast<std::uint64_t>(osm_node_id);
158158
}
159159

include/engine/base64.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <boost/archive/iterators/base64_from_binary.hpp>
1414
#include <boost/archive/iterators/binary_from_base64.hpp>
1515
#include <boost/archive/iterators/transform_width.hpp>
16-
#include <boost/range/algorithm/copy.hpp>
1716

1817
namespace osrm
1918
{

include/engine/datafacade/datafacade_base.hpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
#include "util/typedefs.hpp"
3030

3131
#include "osrm/coordinate.hpp"
32-
33-
#include <boost/range/adaptor/reversed.hpp>
34-
#include <boost/range/any_range.hpp>
3532
#include <cstddef>
3633

3734
#include <engine/bearing.hpp>
3835
#include <optional>
36+
#include <ranges>
3937
#include <string>
4038
#include <string_view>
4139
#include <utility>
@@ -50,20 +48,21 @@ class BaseDataFacade
5048
using RTreeLeaf = extractor::EdgeBasedNodeSegment;
5149

5250
using NodeForwardRange =
53-
boost::iterator_range<extractor::SegmentDataView::SegmentNodeVector::const_iterator>;
54-
using NodeReverseRange = boost::reversed_range<const NodeForwardRange>;
51+
std::ranges::subrange<extractor::SegmentDataView::SegmentNodeVector::const_iterator>;
52+
using NodeReverseRange = std::ranges::reverse_view<NodeForwardRange>;
5553

5654
using WeightForwardRange =
57-
boost::iterator_range<extractor::SegmentDataView::SegmentWeightVector::const_iterator>;
58-
using WeightReverseRange = boost::reversed_range<const WeightForwardRange>;
55+
std::ranges::subrange<extractor::SegmentDataView::SegmentWeightVector::const_iterator>;
56+
57+
using WeightReverseRange = std::ranges::reverse_view<WeightForwardRange>;
5958

6059
using DurationForwardRange =
61-
boost::iterator_range<extractor::SegmentDataView::SegmentDurationVector::const_iterator>;
62-
using DurationReverseRange = boost::reversed_range<const DurationForwardRange>;
60+
std::ranges::subrange<extractor::SegmentDataView::SegmentDurationVector::const_iterator>;
61+
using DurationReverseRange = std::ranges::reverse_view<DurationForwardRange>;
6362

6463
using DatasourceForwardRange =
65-
boost::iterator_range<extractor::SegmentDataView::SegmentDatasourceVector::const_iterator>;
66-
using DatasourceReverseRange = boost::reversed_range<const DatasourceForwardRange>;
64+
std::ranges::subrange<extractor::SegmentDataView::SegmentDatasourceVector::const_iterator>;
65+
using DatasourceReverseRange = std::ranges::reverse_view<DatasourceForwardRange>;
6766

6867
BaseDataFacade() {}
6968
virtual ~BaseDataFacade() {}

include/engine/geospatial_query.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
394394
alias_cast<EdgeDuration>(forward_durations[data.fwd_segment_position]);
395395
EdgeDistance forward_distance =
396396
to_alias<EdgeDistance>(util::coordinate_calculation::greatCircleDistance(
397-
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position)),
397+
datafacade.GetCoordinateOfNode(forward_geometry[data.fwd_segment_position]),
398398
point_on_segment));
399399

400400
const auto reverse_weight_offset = alias_cast<EdgeWeight>(
@@ -426,7 +426,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
426426
EdgeDistance reverse_distance =
427427
to_alias<EdgeDistance>(util::coordinate_calculation::greatCircleDistance(
428428
point_on_segment,
429-
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position + 1))));
429+
datafacade.GetCoordinateOfNode(forward_geometry[data.fwd_segment_position + 1])));
430430

431431
ratio = std::min(1.0, std::max(0.0, ratio));
432432
if (data.forward_segment_id.id != SPECIAL_SEGMENTID)

include/engine/guidance/assemble_geometry.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
6161
const auto source_geometry_id = facade.GetGeometryIndex(source_node_id).id;
6262
const auto source_geometry = facade.GetUncompressedForwardGeometry(source_geometry_id);
6363

64-
geometry.node_ids.push_back(source_geometry(source_segment_start_coordinate));
64+
geometry.node_ids.push_back(source_geometry[source_segment_start_coordinate]);
6565

6666
auto cumulative_distance = 0.;
6767
auto current_distance = 0.;
@@ -142,7 +142,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
142142
LegGeometry::Annotation{current_distance,
143143
duration,
144144
weight,
145-
forward_datasources(target_node.fwd_segment_position)});
145+
forward_datasources[target_node.fwd_segment_position]});
146146
}
147147
else
148148
{
@@ -154,7 +154,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
154154
from_alias<double>(reversed_target ? target_node.reverse_weight
155155
: target_node.forward_weight) /
156156
facade.GetWeightMultiplier(),
157-
forward_datasources(target_node.fwd_segment_position)});
157+
forward_datasources[target_node.fwd_segment_position]});
158158
}
159159

160160
geometry.segment_offsets.push_back(geometry.locations.size());
@@ -168,7 +168,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
168168
const auto target_segment_end_coordinate =
169169
target_node.fwd_segment_position + (reversed_target ? 0 : 1);
170170
const auto target_geometry = facade.GetUncompressedForwardGeometry(target_geometry_id);
171-
geometry.node_ids.push_back(target_geometry(target_segment_end_coordinate));
171+
geometry.node_ids.push_back(target_geometry[target_segment_end_coordinate]);
172172

173173
BOOST_ASSERT(geometry.segment_distances.size() == geometry.segment_offsets.size() - 1);
174174
BOOST_ASSERT(geometry.locations.size() > geometry.segment_distances.size());

include/engine/guidance/route_step.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <string>
1515
#include <vector>
1616

17-
#include <boost/range/iterator_range.hpp>
17+
#include <ranges>
1818

1919
namespace osrm::engine::guidance
2020
{
@@ -220,14 +220,14 @@ inline auto RouteStep::LanesToTheLeft() const
220220
{
221221
const auto &description = intersections.front().lane_description;
222222
LaneID num_lanes_left = NumLanesToTheLeft();
223-
return boost::make_iterator_range(description.begin(), description.begin() + num_lanes_left);
223+
return std::ranges::subrange(description.begin(), description.begin() + num_lanes_left);
224224
}
225225

226226
inline auto RouteStep::LanesToTheRight() const
227227
{
228228
const auto &description = intersections.front().lane_description;
229229
LaneID num_lanes_right = NumLanesToTheRight();
230-
return boost::make_iterator_range(description.end() - num_lanes_right, description.end());
230+
return std::ranges::subrange(description.end() - num_lanes_right, description.end());
231231
}
232232

233233
} // namespace osrm::engine::guidance

include/extractor/class_data.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <algorithm>
77
#include <cctype>
88
#include <cstdint>
9+
#include <limits>
10+
#include <string>
911

1012
namespace osrm::extractor
1113
{

include/extractor/node_restriction_map.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include "restriction_graph.hpp"
66
#include "util/typedefs.hpp"
77

8-
#include <boost/range/adaptor/filtered.hpp>
9-
108
#include <unordered_map>
119
#include <utility>
1210
#include <vector>
@@ -26,15 +24,15 @@ template <typename RestrictionFilter> class NodeRestrictionMap
2624
// Find all restrictions applicable to (from,via,*) turns
2725
auto Restrictions(NodeID from, NodeID via) const
2826
{
29-
return getRange(from, via) | boost::adaptors::filtered(index_filter);
27+
return getRange(from, via) | std::views::filter(index_filter);
3028
};
3129

3230
// Find all restrictions applicable to (from,via,to) turns
3331
auto Restrictions(NodeID from, NodeID via, NodeID to) const
3432
{
3533
const auto turnFilter = [this, to](const auto &restriction)
3634
{ return index_filter(restriction) && restriction->IsTurnRestricted(to); };
37-
return getRange(from, via) | boost::adaptors::filtered(turnFilter);
35+
return getRange(from, via) | std::views::filter(turnFilter);
3836
};
3937

4038
private:

include/extractor/restriction_graph.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "util/node_based_graph.hpp"
77
#include "util/std_hash.hpp"
88
#include "util/typedefs.hpp"
9-
9+
#include <ranges>
1010
#include <unordered_map>
1111

1212
namespace osrm::extractor
@@ -102,9 +102,9 @@ struct RestrictionGraph
102102
friend restriction_graph_details::transferBuilder;
103103
friend RestrictionGraph constructRestrictionGraph(const std::vector<TurnRestriction> &);
104104

105-
using EdgeRange = boost::iterator_range<std::vector<RestrictionEdge>::const_iterator>;
105+
using EdgeRange = std::ranges::subrange<std::vector<RestrictionEdge>::const_iterator>;
106106
using RestrictionRange =
107-
boost::iterator_range<std::vector<const TurnRestriction *>::const_iterator>;
107+
std::ranges::subrange<std::vector<const TurnRestriction *>::const_iterator>;
108108
using EdgeKey = std::pair<NodeID, NodeID>;
109109

110110
// Helper functions for iterating over node restrictions and edges

0 commit comments

Comments
 (0)