From 0b1748af3bb0ca075f434d74d205226bb98c8c18 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Tue, 21 May 2024 20:56:28 +0200 Subject: [PATCH] use std::nullopt --- src/guidance/intersection_handler.cpp | 4 ++-- src/guidance/sliproad_handler.cpp | 10 +++++----- src/guidance/turn_handler.cpp | 4 ++-- src/util/coordinate_calculation.cpp | 8 ++++---- src/util/timezones.cpp | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/guidance/intersection_handler.cpp b/src/guidance/intersection_handler.cpp index d08cbcdbc..b11597d5f 100644 --- a/src/guidance/intersection_handler.cpp +++ b/src/guidance/intersection_handler.cpp @@ -450,7 +450,7 @@ IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) cons if (intersection_parameters.node == SPECIAL_NODEID || intersection_parameters.edge == SPECIAL_EDGEID) { - return {}; + return std::nullopt; } auto intersection = extractor::intersection::getConnectedRoads(node_based_graph, @@ -465,7 +465,7 @@ IntersectionHandler::getNextIntersection(const NodeID at, const EdgeID via) cons if (intersection.size() <= 2 || intersection.isTrafficSignalOrBarrier()) { - return {}; + return std::nullopt; } return std::make_optional(IntersectionViewAndNode{std::move(intersection), intersection_node}); diff --git a/src/guidance/sliproad_handler.cpp b/src/guidance/sliproad_handler.cpp index ae4baf4b7..90a92801f 100644 --- a/src/guidance/sliproad_handler.cpp +++ b/src/guidance/sliproad_handler.cpp @@ -652,7 +652,7 @@ std::optional SliproadHandler::getObviousIndexWithSliproads( // then the non-Sliproad is the obvious one. if (intersection.size() != 3) { - return {}; + return std::nullopt; } const auto forking = intersection[1].instruction.type == TurnType::Fork && @@ -660,7 +660,7 @@ std::optional SliproadHandler::getObviousIndexWithSliproads( if (!forking) { - return {}; + return std::nullopt; } const auto first = getNextIntersection(at, intersection.getRightmostRoad().eid); @@ -668,12 +668,12 @@ std::optional SliproadHandler::getObviousIndexWithSliproads( if (!first || !second) { - return {}; + return std::nullopt; } if (first->intersection.isDeadEnd() || second->intersection.isDeadEnd()) { - return {}; + return std::nullopt; } // In case of loops at the end of the road, we will arrive back at the intersection @@ -688,7 +688,7 @@ std::optional SliproadHandler::getObviousIndexWithSliproads( return std::make_optional(std::size_t{1}); } - return {}; + return std::nullopt; } bool SliproadHandler::nextIntersectionIsTooFarAway(const NodeID start, const EdgeID onto) const diff --git a/src/guidance/turn_handler.cpp b/src/guidance/turn_handler.cpp index 8fd5c43d0..0a7724360 100644 --- a/src/guidance/turn_handler.cpp +++ b/src/guidance/turn_handler.cpp @@ -647,7 +647,7 @@ TurnHandler::findForkCandidatesByGeometry(Intersection &intersection) const } } } - return {}; + return std::nullopt; } // check if the fork candidates (all roads between left and right) and the @@ -740,7 +740,7 @@ std::optional TurnHandler::findFork(const EdgeID via_edge, } } - return {}; + return std::nullopt; } void TurnHandler::handleDistinctConflict(const EdgeID via_edge, diff --git a/src/util/coordinate_calculation.cpp b/src/util/coordinate_calculation.cpp index 72c61a6eb..00c5efbf5 100644 --- a/src/util/coordinate_calculation.cpp +++ b/src/util/coordinate_calculation.cpp @@ -181,7 +181,7 @@ circleCenter(const Coordinate C1, const Coordinate C2, const Coordinate C3) // require three distinct points if (C1 == C2 || C2 == C3 || C1 == C3) { - return {}; + return std::nullopt; } // define line through c1, c2 and c2,c3 @@ -196,7 +196,7 @@ circleCenter(const Coordinate C1, const Coordinate C2, const Coordinate C3) (std::abs(C2C1_lat) < std::numeric_limits::epsilon() && std::abs(C3C2_lat) < std::numeric_limits::epsilon())) { - return {}; + return std::nullopt; } else if (std::abs(C2C1_lon) < std::numeric_limits::epsilon()) { @@ -234,7 +234,7 @@ circleCenter(const Coordinate C1, const Coordinate C2, const Coordinate C3) // can this ever happen? if (std::abs(C2C1_slope - C3C2_slope) < std::numeric_limits::epsilon()) - return {}; + return std::nullopt; const double C1_y = static_cast(toFloating(C1.lat)); const double C1_x = static_cast(toFloating(C1.lon)); @@ -248,7 +248,7 @@ circleCenter(const Coordinate C1, const Coordinate C2, const Coordinate C3) (2 * (C3C2_slope - C2C1_slope)); const double lat = (0.5 * (C1_x + C2_x) - lon) / C2C1_slope + 0.5 * (C1_y + C2_y); if (lon < -180.0 || lon > 180.0 || lat < -90.0 || lat > 90.0) - return {}; + return std::nullopt; else return Coordinate(FloatLongitude{lon}, FloatLatitude{lat}); } diff --git a/src/util/timezones.cpp b/src/util/timezones.cpp index e7ef96356..3fd527d69 100644 --- a/src/util/timezones.cpp +++ b/src/util/timezones.cpp @@ -168,6 +168,6 @@ std::optional Timezoner::operator()(const point_t &point) const if (boost::geometry::within(point, local_times[index].first)) return local_times[index].second; } - return {}; + return std::nullopt; } } // namespace osrm::updater