use std::nullopt

This commit is contained in:
Siarhei Fedartsou 2024-05-21 20:56:28 +02:00 committed by GitHub
parent c579436a78
commit 0b1748af3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 14 deletions

View File

@ -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<false>(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});

View File

@ -652,7 +652,7 @@ std::optional<std::size_t> 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<std::size_t> SliproadHandler::getObviousIndexWithSliproads(
if (!forking)
{
return {};
return std::nullopt;
}
const auto first = getNextIntersection(at, intersection.getRightmostRoad().eid);
@ -668,12 +668,12 @@ std::optional<std::size_t> 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<std::size_t> SliproadHandler::getObviousIndexWithSliproads(
return std::make_optional(std::size_t{1});
}
return {};
return std::nullopt;
}
bool SliproadHandler::nextIntersectionIsTooFarAway(const NodeID start, const EdgeID onto) const

View File

@ -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::Fork> TurnHandler::findFork(const EdgeID via_edge,
}
}
return {};
return std::nullopt;
}
void TurnHandler::handleDistinctConflict(const EdgeID via_edge,

View File

@ -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<double>::epsilon() &&
std::abs(C3C2_lat) < std::numeric_limits<double>::epsilon()))
{
return {};
return std::nullopt;
}
else if (std::abs(C2C1_lon) < std::numeric_limits<double>::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<double>::epsilon())
return {};
return std::nullopt;
const double C1_y = static_cast<double>(toFloating(C1.lat));
const double C1_x = static_cast<double>(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});
}

View File

@ -168,6 +168,6 @@ std::optional<struct tm> 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