Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/openlr
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2019-12-25 17:48:04 +0300
committerMaksim Andrianov <maksimandrianov1@gmail.com>2019-12-26 16:57:43 +0300
commit01fdd7fc4998ceea2c8edb0d5b7a5255fd72ea87 (patch)
tree60c0ffafb151a0dad35b4aa98f451ff968bc1d83 /openlr
parentf5de0be1e3d79bad0fc53980536daf85b3823218 (diff)
[omim] Replaced boost::optional with std::optional.
Since C++17, optional is part of the C++ Standard Library.
Diffstat (limited to 'openlr')
-rw-r--r--openlr/helpers.cpp38
-rw-r--r--openlr/openlr_model_xml.cpp17
2 files changed, 26 insertions, 29 deletions
diff --git a/openlr/helpers.cpp b/openlr/helpers.cpp
index eecd7a1edd..ce7928f2b5 100644
--- a/openlr/helpers.cpp
+++ b/openlr/helpers.cpp
@@ -7,12 +7,11 @@
#include "geometry/mercator.hpp"
#include <algorithm>
+#include <optional>
#include <sstream>
#include <string>
#include <type_traits>
-#include "boost/optional.hpp"
-
namespace
{
using namespace openlr;
@@ -32,15 +31,15 @@ openlr::FunctionalRoadClass HighwayClassToFunctionalRoadClass(ftypes::HighwayCla
}
}
-/// \returns boost::none if |e| doesn't conform to |functionalRoadClass| and score otherwise.
-boost::optional<Score> GetFrcScore(Graph::Edge const & e, FunctionalRoadClass functionalRoadClass,
- RoadInfoGetter & infoGetter)
+/// \returns nullopt if |e| doesn't conform to |functionalRoadClass| and score otherwise.
+optional<Score> GetFrcScore(Graph::Edge const & e, FunctionalRoadClass functionalRoadClass,
+ RoadInfoGetter & infoGetter)
{
CHECK(!e.IsFake(), ());
Score constexpr kMaxScoreForFrc = 25;
if (functionalRoadClass == FunctionalRoadClass::NotAValue)
- return boost::none;
+ return nullopt;
auto const hwClass = infoGetter.Get(e.GetFeatureId()).m_hwClass;
@@ -48,35 +47,34 @@ boost::optional<Score> GetFrcScore(Graph::Edge const & e, FunctionalRoadClass fu
{
case FunctionalRoadClass::FRC0:
// Note. HighwayClass::Trunk means motorway, motorway_link, trunk or trunk_link.
- return hwClass == ftypes::HighwayClass::Trunk ? boost::optional<Score>(kMaxScoreForFrc)
- : boost::none;
+ return hwClass == ftypes::HighwayClass::Trunk ? optional<Score>(kMaxScoreForFrc) : nullopt;
case FunctionalRoadClass::FRC1:
return (hwClass == ftypes::HighwayClass::Trunk || hwClass == ftypes::HighwayClass::Primary)
- ? boost::optional<Score>(kMaxScoreForFrc)
- : boost::none;
+ ? optional<Score>(kMaxScoreForFrc)
+ : nullopt;
case FunctionalRoadClass::FRC2:
case FunctionalRoadClass::FRC3:
if (hwClass == ftypes::HighwayClass::Secondary || hwClass == ftypes::HighwayClass::Tertiary)
- return boost::optional<Score>(kMaxScoreForFrc);
+ return optional<Score>(kMaxScoreForFrc);
return hwClass == ftypes::HighwayClass::Primary || hwClass == ftypes::HighwayClass::LivingStreet
- ? boost::optional<Score>(0)
- : boost::none;
+ ? optional<Score>(0)
+ : nullopt;
case FunctionalRoadClass::FRC4:
if (hwClass == ftypes::HighwayClass::LivingStreet || hwClass == ftypes::HighwayClass::Service)
- return boost::optional<Score>(kMaxScoreForFrc);
+ return optional<Score>(kMaxScoreForFrc);
- return hwClass == ftypes::HighwayClass::Tertiary ? boost::optional<Score>(0) : boost::none;
+ return hwClass == ftypes::HighwayClass::Tertiary ? optional<Score>(0) : nullopt;
case FunctionalRoadClass::FRC5:
case FunctionalRoadClass::FRC6:
case FunctionalRoadClass::FRC7:
return hwClass == ftypes::HighwayClass::LivingStreet || hwClass == ftypes::HighwayClass::Service
- ? boost::optional<Score>(kMaxScoreForFrc)
- : boost::none;
+ ? optional<Score>(kMaxScoreForFrc)
+ : nullopt;
case FunctionalRoadClass::NotAValue:
UNREACHABLE();
@@ -168,10 +166,10 @@ bool PassesRestrictionV3(Graph::Edge const & e, FunctionalRoadClass functionalRo
{
CHECK(!e.IsFake(), ("Edges should not be fake:", e));
auto const frcScore = GetFrcScore(e, functionalRoadClass, infoGetter);
- if (frcScore == boost::none)
+ if (!frcScore)
return false;
- score = frcScore.get();
+ score = *frcScore;
Score constexpr kScoreForFormOfWay = 25;
if (formOfWay == FormOfWay::Roundabout && infoGetter.Get(e.GetFeatureId()).m_isRoundabout)
score += kScoreForFormOfWay;
@@ -192,7 +190,7 @@ bool ConformLfrcnp(Graph::Edge const & e, FunctionalRoadClass lowestFrcToNextPoi
bool ConformLfrcnpV3(Graph::Edge const & e, FunctionalRoadClass lowestFrcToNextPoint,
RoadInfoGetter & infoGetter)
{
- return GetFrcScore(e, lowestFrcToNextPoint, infoGetter) != boost::none;
+ return GetFrcScore(e, lowestFrcToNextPoint, infoGetter).has_value();
}
size_t IntersectionLen(Graph::EdgeVector a, Graph::EdgeVector b)
diff --git a/openlr/openlr_model_xml.cpp b/openlr/openlr_model_xml.cpp
index 07d87529fc..a65128b2f3 100644
--- a/openlr/openlr_model_xml.cpp
+++ b/openlr/openlr_model_xml.cpp
@@ -6,10 +6,9 @@
#include "base/logging.hpp"
#include <cstring>
+#include <optional>
#include <type_traits>
-#include "boost/optional.hpp"
-
#include "3party/pugixml/src/pugixml.hpp"
using namespace std;
@@ -27,9 +26,9 @@ bool IntegerFromXML(pugi::xml_node const & node, Value & value)
return true;
}
-boost::optional<double> DoubleFromXML(pugi::xml_node const & node)
+std::optional<double> DoubleFromXML(pugi::xml_node const & node)
{
- return node ? node.text().as_double() : boost::optional<double>();
+ return node ? node.text().as_double() : std::optional<double>();
}
bool GetLatLon(pugi::xml_node const & node, int32_t & lat, int32_t & lon)
@@ -112,12 +111,12 @@ bool FirstCoordinateFromXML(pugi::xml_node const & node, ms::LatLon & latLon)
return true;
}
-boost::optional<ms::LatLon> LatLonFormXML(pugi::xml_node const & node)
+std::optional<ms::LatLon> LatLonFormXML(pugi::xml_node const & node)
{
auto const lat = DoubleFromXML(node.child("latitude"));
auto const lon = DoubleFromXML(node.child("longitude"));
- return lat && lon ? ms::LatLon(lat.get(), lon.get()) : ms::LatLon::Zero();
+ return lat && lon ? ms::LatLon(*lat, *lon) : ms::LatLon::Zero();
}
bool CoordinateFromXML(pugi::xml_node const & node, ms::LatLon const & prevCoord,
@@ -294,10 +293,10 @@ bool CoordinatesFromXML(pugi::xml_node const & coordsNode, openlr::LinearLocatio
return false;
}
- LOG(LINFO, ("from:", latLonStart.get(), "to:", latLonEnd.get()));
+ LOG(LINFO, ("from:", *latLonStart, "to:", *latLonEnd));
locRef.m_points.resize(2);
- locRef.m_points[0].m_latLon = latLonStart.get();
- locRef.m_points[1].m_latLon = latLonEnd.get();
+ locRef.m_points[0].m_latLon = *latLonStart;
+ locRef.m_points[1].m_latLon = *latLonEnd;
return true;
}
} // namespace