Skip to content

Commit efe6840

Browse files
authored
Replace boost::optional with std::optional (#6611)
1 parent d259848 commit efe6840

25 files changed

+105
-108
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- NodeJS:
2020
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
2121
- Misc:
22+
- CHANGED: Partial fix migration from boost::optional to std::optional [#6551](https://github.com/Project-OSRM/osrm-backend/issues/6551)
2223
- CHANGED: Update Conan Boost version to 1.85.0. [#6868](https://github.com/Project-OSRM/osrm-backend/pull/6868)
2324
- FIXED: Fix an error in a RouteParameters AnnotationsType operator overload. [#6646](https://github.com/Project-OSRM/osrm-backend/pull/6646)
2425
- ADDED: Add support for "unlimited" to be passed as a value for the default-radius and max-matching-radius flags. [#6599](https://github.com/Project-OSRM/osrm-backend/pull/6599)

include/engine/geospatial_query.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include "osrm/coordinate.hpp"
1414

15+
#include <boost/optional.hpp>
16+
1517
#include <algorithm>
1618
#include <cmath>
1719
#include <iterator>

include/engine/routing_algorithms/routing_base_ch.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
122122
const EdgeWeight new_weight = reverseHeapNode->weight + heapNode.weight;
123123
if (new_weight < upper_bound)
124124
{
125-
if (shouldForceStep(force_step_nodes, heapNode, reverseHeapNode.get()) ||
125+
if (shouldForceStep(force_step_nodes, heapNode, *reverseHeapNode) ||
126126
// in this case we are looking at a bi-directional way where the source
127127
// and target phantom are on the same edge based node
128128
new_weight < EdgeWeight{0})

include/engine/routing_algorithms/routing_base_mld.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
408408
auto reverse_weight = reverseHeapNode->weight;
409409
auto path_weight = weight + reverse_weight;
410410

411-
if (!shouldForceStep(force_step_nodes, heapNode, reverseHeapNode.get()) &&
411+
if (!shouldForceStep(force_step_nodes, heapNode, *reverseHeapNode) &&
412412
(path_weight >= EdgeWeight{0}) && (path_weight < path_upper_bound))
413413
{
414414
middle_node = heapNode.node;

include/extractor/intersection/node_based_graph_walker.hpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "util/typedefs.hpp"
1212

1313
#include <boost/assert.hpp>
14-
#include <boost/optional.hpp>
1514
#include <cstdint>
15+
#include <optional>
1616
#include <utility>
1717

1818
namespace osrm::extractor::intersection
@@ -42,10 +42,10 @@ class NodeBasedGraphWalker
4242
* selector not provinding any further edge to traverse)
4343
*/
4444
template <class accumulator_type, class selector_type>
45-
boost::optional<std::pair<NodeID, EdgeID>> TraverseRoad(NodeID starting_at_node_id,
46-
EdgeID following_edge_id,
47-
accumulator_type &accumulator,
48-
const selector_type &selector) const;
45+
std::optional<std::pair<NodeID, EdgeID>> TraverseRoad(NodeID starting_at_node_id,
46+
EdgeID following_edge_id,
47+
accumulator_type &accumulator,
48+
const selector_type &selector) const;
4949

5050
private:
5151
const util::NodeBasedDynamicGraph &node_based_graph;
@@ -111,11 +111,11 @@ struct SelectRoadByNameOnlyChoiceAndStraightness
111111
* traversal. If no such edge is found, return {} is allowed. Usually you want to choose some
112112
* form of obious turn to follow.
113113
*/
114-
boost::optional<EdgeID> operator()(const NodeID nid,
115-
const EdgeID via_edge_id,
116-
const IntersectionView &intersection,
117-
const util::NodeBasedDynamicGraph &node_based_graph,
118-
const EdgeBasedNodeDataContainer &node_data_container) const;
114+
std::optional<EdgeID> operator()(const NodeID nid,
115+
const EdgeID via_edge_id,
116+
const IntersectionView &intersection,
117+
const util::NodeBasedDynamicGraph &node_based_graph,
118+
const EdgeBasedNodeDataContainer &node_data_container) const;
119119

120120
private:
121121
const NameID desired_name_id;
@@ -138,11 +138,11 @@ struct SelectStraightmostRoadByNameAndOnlyChoice
138138
* traversal. If no such edge is found, return {} is allowed. Usually you want to choose some
139139
* form of obious turn to follow.
140140
*/
141-
boost::optional<EdgeID> operator()(const NodeID nid,
142-
const EdgeID via_edge_id,
143-
const IntersectionView &intersection,
144-
const util::NodeBasedDynamicGraph &node_based_graph,
145-
const EdgeBasedNodeDataContainer &node_data_container) const;
141+
std::optional<EdgeID> operator()(const NodeID nid,
142+
const EdgeID via_edge_id,
143+
const IntersectionView &intersection,
144+
const util::NodeBasedDynamicGraph &node_based_graph,
145+
const EdgeBasedNodeDataContainer &node_data_container) const;
146146

147147
private:
148148
const NameID desired_name_id;
@@ -187,7 +187,7 @@ struct IntersectionFinderAccumulator
187187
};
188188

189189
template <class accumulator_type, class selector_type>
190-
boost::optional<std::pair<NodeID, EdgeID>>
190+
std::optional<std::pair<NodeID, EdgeID>>
191191
NodeBasedGraphWalker::TraverseRoad(NodeID current_node_id,
192192
EdgeID current_edge_id,
193193
accumulator_type &accumulator,
@@ -254,19 +254,19 @@ NodeBasedGraphWalker::TraverseRoad(NodeID current_node_id,
254254

255255
struct SkipTrafficSignalBarrierRoadSelector
256256
{
257-
boost::optional<EdgeID> operator()(const NodeID,
258-
const EdgeID,
259-
const IntersectionView &intersection,
260-
const util::NodeBasedDynamicGraph &,
261-
const EdgeBasedNodeDataContainer &) const
257+
std::optional<EdgeID> operator()(const NodeID,
258+
const EdgeID,
259+
const IntersectionView &intersection,
260+
const util::NodeBasedDynamicGraph &,
261+
const EdgeBasedNodeDataContainer &) const
262262
{
263263
if (intersection.isTrafficSignalOrBarrier())
264264
{
265-
return boost::make_optional(intersection[1].eid);
265+
return std::make_optional(intersection[1].eid);
266266
}
267267
else
268268
{
269-
return boost::none;
269+
return std::nullopt;
270270
}
271271
}
272272
};

include/extractor/maneuver_override_relation_parser.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "maneuver_override.hpp"
55

6-
#include <boost/optional.hpp>
6+
#include <optional>
77
#include <string>
88
#include <vector>
99

@@ -55,7 +55,7 @@ class ManeuverOverrideRelationParser
5555
{
5656
public:
5757
ManeuverOverrideRelationParser();
58-
boost::optional<InputManeuverOverride> TryParse(const osmium::Relation &relation) const;
58+
std::optional<InputManeuverOverride> TryParse(const osmium::Relation &relation) const;
5959
};
6060
} // namespace osrm::extractor
6161

include/extractor/profile_properties.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
#include <boost/assert.hpp>
99
#include <boost/numeric/conversion/cast.hpp>
10-
#include <boost/optional.hpp>
1110

1211
#include <algorithm>
1312
#include <array>
1413
#include <cstdint>
14+
#include <optional>
1515

1616
namespace osrm::extractor
1717
{
@@ -80,7 +80,7 @@ struct ProfileProperties
8080
}
8181

8282
// Check if this classes are excludable
83-
boost::optional<std::size_t> ClassesAreExcludable(ClassData classes) const
83+
std::optional<std::size_t> ClassesAreExcludable(ClassData classes) const
8484
{
8585
auto iter = std::find(excludable_classes.begin(), excludable_classes.end(), classes);
8686
if (iter != excludable_classes.end())

include/guidance/intersection_handler.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515

1616
#include <algorithm>
1717
#include <cstddef>
18+
#include <optional>
1819
#include <utility>
1920
#include <vector>
2021

21-
#include <boost/optional.hpp>
22-
2322
namespace osrm::guidance
2423
{
2524

@@ -129,7 +128,7 @@ class IntersectionHandler
129128
// ^ via
130129
//
131130
// For this scenario returns intersection at `b` and `b`.
132-
boost::optional<IntersectionHandler::IntersectionViewAndNode>
131+
std::optional<IntersectionHandler::IntersectionViewAndNode>
133132
getNextIntersection(const NodeID at, const EdgeID via) const;
134133

135134
bool isSameName(const EdgeID source_edge_id, const EdgeID target_edge_id) const;

include/guidance/sliproad_handler.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
#include "util/node_based_graph.hpp"
1111

12+
#include <optional>
1213
#include <vector>
1314

14-
#include <boost/optional.hpp>
15-
1615
namespace osrm::guidance
1716
{
1817

@@ -43,9 +42,9 @@ class SliproadHandler final : public IntersectionHandler
4342
Intersection intersection) const override final;
4443

4544
private:
46-
boost::optional<std::size_t> getObviousIndexWithSliproads(const EdgeID from,
47-
const Intersection &intersection,
48-
const NodeID at) const;
45+
std::optional<std::size_t> getObviousIndexWithSliproads(const EdgeID from,
46+
const Intersection &intersection,
47+
const NodeID at) const;
4948

5049
// Next intersection from `start` onto `onto` is too far away for a Siproad scenario
5150
bool nextIntersectionIsTooFarAway(const NodeID start, const EdgeID onto) const;

include/guidance/turn_handler.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
#include "util/attributes.hpp"
1212
#include "util/node_based_graph.hpp"
1313

14-
#include <boost/optional.hpp>
15-
1614
#include <cstddef>
15+
#include <optional>
1716
#include <utility>
1817
#include <vector>
1918

@@ -72,7 +71,7 @@ class TurnHandler final : public IntersectionHandler
7271

7372
bool hasObvious(const EdgeID &via_edge, const Fork &fork) const;
7473

75-
boost::optional<Fork> findForkCandidatesByGeometry(Intersection &intersection) const;
74+
std::optional<Fork> findForkCandidatesByGeometry(Intersection &intersection) const;
7675

7776
bool isCompatibleByRoadClass(const Intersection &intersection, const Fork fork) const;
7877

@@ -96,7 +95,7 @@ class TurnHandler final : public IntersectionHandler
9695
handleDistinctConflict(const EdgeID via_edge, ConnectedRoad &left, ConnectedRoad &right) const;
9796

9897
// Classification
99-
boost::optional<Fork> findFork(const EdgeID via_edge, Intersection &intersection) const;
98+
std::optional<Fork> findFork(const EdgeID via_edge, Intersection &intersection) const;
10099

101100
OSRM_ATTR_WARN_UNUSED
102101
Intersection assignLeftTurns(const EdgeID via_edge,

0 commit comments

Comments
 (0)