From 371dc57dfca56b33653e8f241dea7ca7387e2487 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Thu, 1 Feb 2018 15:16:38 +0000 Subject: [PATCH] Fix uninitialized warning because of boost::optional --- src/extractor/restriction_parser.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/extractor/restriction_parser.cpp b/src/extractor/restriction_parser.cpp index f991c9e50..7c8f27031 100644 --- a/src/extractor/restriction_parser.cpp +++ b/src/extractor/restriction_parser.cpp @@ -127,7 +127,10 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const InputConditionalTurnRestriction restriction_container; restriction_container.is_only = is_only_restriction; - boost::optional from = boost::none, via = boost::none, to = boost::none; + constexpr auto INVALID_OSM_ID = std::numeric_limits::max(); + auto from = INVALID_OSM_ID; + auto via = INVALID_OSM_ID; + auto to = INVALID_OSM_ID; bool is_node_restriction = true; for (const auto &member : relation.members()) @@ -208,17 +211,17 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const } } - if (from && via && to) + if (from != INVALID_OSM_ID && via != INVALID_OSM_ID && to != INVALID_OSM_ID) { if (is_node_restriction) { // template struct requires bracket for ID initialisation :( - restriction_container.node_or_way = InputNodeRestriction{{*from}, {*via}, {*to}}; + restriction_container.node_or_way = InputNodeRestriction{{from}, {via}, {to}}; } else { // template struct requires bracket for ID initialisation :( - restriction_container.node_or_way = InputWayRestriction{{*from}, {*via}, {*to}}; + restriction_container.node_or_way = InputWayRestriction{{from}, {via}, {to}}; } return restriction_container; }