Use std::ranges::subrange instead of boost::iterator_range

This commit is contained in:
Siarhei Fedartsou
2024-07-13 18:42:15 +02:00
parent 8ae9abaa63
commit 01ab85192f
11 changed files with 27 additions and 31 deletions
+3 -3
View File
@@ -14,7 +14,7 @@
#include <string>
#include <vector>
#include <boost/range/iterator_range.hpp>
#include <ranges>
namespace osrm::engine::guidance
{
@@ -220,14 +220,14 @@ inline auto RouteStep::LanesToTheLeft() const
{
const auto &description = intersections.front().lane_description;
LaneID num_lanes_left = NumLanesToTheLeft();
return boost::make_iterator_range(description.begin(), description.begin() + num_lanes_left);
return std::ranges::subrange(description.begin(), description.begin() + num_lanes_left);
}
inline auto RouteStep::LanesToTheRight() const
{
const auto &description = intersections.front().lane_description;
LaneID num_lanes_right = NumLanesToTheRight();
return boost::make_iterator_range(description.end() - num_lanes_right, description.end());
return std::ranges::subrange(description.end() - num_lanes_right, description.end());
}
} // namespace osrm::engine::guidance
+1
View File
@@ -6,6 +6,7 @@
#include <algorithm>
#include <cctype>
#include <cstdint>
#include <string>
namespace osrm::extractor
{
+2 -2
View File
@@ -26,7 +26,7 @@ template <typename RestrictionFilter> class NodeRestrictionMap
// Find all restrictions applicable to (from,via,*) turns
auto Restrictions(NodeID from, NodeID via) const
{
return getRange(from, via) | boost::adaptors::filtered(index_filter);
return getRange(from, via) | std::views::filter(index_filter);
};
// Find all restrictions applicable to (from,via,to) turns
@@ -34,7 +34,7 @@ template <typename RestrictionFilter> class NodeRestrictionMap
{
const auto turnFilter = [this, to](const auto &restriction)
{ return index_filter(restriction) && restriction->IsTurnRestricted(to); };
return getRange(from, via) | boost::adaptors::filtered(turnFilter);
return getRange(from, via) | std::views::filter(turnFilter);
};
private:
+3 -3
View File
@@ -6,7 +6,7 @@
#include "util/node_based_graph.hpp"
#include "util/std_hash.hpp"
#include "util/typedefs.hpp"
#include <ranges>
#include <unordered_map>
namespace osrm::extractor
@@ -102,9 +102,9 @@ struct RestrictionGraph
friend restriction_graph_details::transferBuilder;
friend RestrictionGraph constructRestrictionGraph(const std::vector<TurnRestriction> &);
using EdgeRange = boost::iterator_range<std::vector<RestrictionEdge>::const_iterator>;
using EdgeRange = std::ranges::subrange<std::vector<RestrictionEdge>::const_iterator>;
using RestrictionRange =
boost::iterator_range<std::vector<const TurnRestriction *>::const_iterator>;
std::ranges::subrange<std::vector<const TurnRestriction *>::const_iterator>;
using EdgeKey = std::pair<NodeID, NodeID>;
// Helper functions for iterating over node restrictions and edges
+2 -2
View File
@@ -5,7 +5,7 @@
#include <boost/iterator/filter_iterator.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/range/iterator_range.hpp>
#include <ranges>
#include <cstddef>
#include <cstdint>
@@ -40,7 +40,7 @@ class BisectionGraphView
// Iteration over all nodes (direct access into the node)
ConstNodeIterator Begin() const;
ConstNodeIterator End() const;
auto Nodes() const { return boost::make_iterator_range(begin, end); }
auto Nodes() const { return std::ranges::subrange(begin, end); }
// Re-Construct the ID of a node from a reference
NodeID GetID(const NodeT &node) const;
+2 -2
View File
@@ -4,7 +4,7 @@
#include "util/msb.hpp"
#include <boost/iterator/iterator_facade.hpp>
#include <boost/range/iterator_range.hpp>
#include <ranges>
namespace osrm::util
{
@@ -88,7 +88,7 @@ class BitIterator : public boost::iterator_facade<BitIterator<DataT>,
// Returns range over all 1 bits of value
template <typename T> auto makeBitRange(const T value)
{
return boost::make_iterator_range(BitIterator<T>{value}, BitIterator<T>{});
return std::ranges::subrange(BitIterator<T>{value}, BitIterator<T>{});
}
} // namespace osrm::util