diff --git a/.clang-tidy b/.clang-tidy index 1d41cdd58d2..495e4fc6af4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,6 +17,7 @@ Checks: > -bugprone-incorrect-enable-if, -bugprone-switch-missing-default-case, -bugprone-empty-catch, + -bugprone-unchecked-optional-access, -clang-analyzer-*, -clang-diagnostic-deprecated-declarations, -clang-diagnostic-constant-conversion, diff --git a/CHANGELOG.md b/CHANGELOG.md index 23170c79de2..d4ba8226934 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - NodeJS: - CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452) - Misc: + - CHANGED: Get rid of boost::optional leftovers. [#6977](https://github.com/Project-OSRM/osrm-backend/pull/6977) - CHANGED: Use Link Time Optimisation whenever possible. [#6967](https://github.com/Project-OSRM/osrm-backend/pull/6967) - CHANGED: Use struct instead of tuple to define UnpackedPath. [#6974](https://github.com/Project-OSRM/osrm-backend/pull/6974) - CHANGED: Micro performance optimisation in map matching. [#6976](https://github.com/Project-OSRM/osrm-backend/pull/6976) diff --git a/include/engine/api/base_parameters.hpp b/include/engine/api/base_parameters.hpp index d7422566f0a..1a35a030d8b 100644 --- a/include/engine/api/base_parameters.hpp +++ b/include/engine/api/base_parameters.hpp @@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "engine/hint.hpp" #include "util/coordinate.hpp" -#include +#include #include #include @@ -74,12 +74,12 @@ struct BaseParameters }; std::vector coordinates; - std::vector> hints; - std::vector> radiuses; - std::vector> bearings; - std::vector> approaches; + std::vector> hints; + std::vector> radiuses; + std::vector> bearings; + std::vector> approaches; std::vector exclude; - boost::optional format = OutputFormatType::JSON; + std::optional format = OutputFormatType::JSON; // Adds hints to response which can be included in subsequent requests, see `hints` above. bool generate_hints = true; @@ -90,10 +90,10 @@ struct BaseParameters SnappingType snapping = SnappingType::Default; BaseParameters(std::vector coordinates_ = {}, - std::vector> hints_ = {}, - std::vector> radiuses_ = {}, - std::vector> bearings_ = {}, - std::vector> approaches_ = {}, + std::vector> hints_ = {}, + std::vector> radiuses_ = {}, + std::vector> bearings_ = {}, + std::vector> approaches_ = {}, bool generate_hints_ = true, std::vector exclude = {}, const SnappingType snapping_ = SnappingType::Default) @@ -112,7 +112,7 @@ struct BaseParameters (approaches.empty() || approaches.size() == coordinates.size()) && std::all_of(bearings.begin(), bearings.end(), - [](const boost::optional &bearing_and_range) + [](const std::optional &bearing_and_range) { if (bearing_and_range) { diff --git a/include/engine/api/json_factory.hpp b/include/engine/api/json_factory.hpp index 1175dcd7e2a..001f44ff851 100644 --- a/include/engine/api/json_factory.hpp +++ b/include/engine/api/json_factory.hpp @@ -12,7 +12,7 @@ #include "util/coordinate.hpp" #include "util/json_container.hpp" -#include +#include #include #include @@ -90,7 +90,7 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo util::json::Object makeRoute(const guidance::Route &route, util::json::Array legs, - boost::optional geometry, + std::optional geometry, const char *weight_name); // Creates a Waypoint without Hint, see the Hint overload below diff --git a/include/engine/api/nearest_api.hpp b/include/engine/api/nearest_api.hpp index beae38cec33..0e2a9edbfdf 100644 --- a/include/engine/api/nearest_api.hpp +++ b/include/engine/api/nearest_api.hpp @@ -45,7 +45,7 @@ class NearestAPI final : public BaseAPI flatbuffers::FlatBufferBuilder &fb_result) const { auto data_timestamp = facade.GetTimestamp(); - boost::optional> data_version_string = boost::none; + std::optional> data_version_string = std::nullopt; if (!data_timestamp.empty()) { data_version_string = fb_result.CreateString(data_timestamp); diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index 211be7f8d19..fb1830ce361 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -184,10 +184,10 @@ class RouteAPI : public BaseAPI return builder.CreateVectorOfStructs(coordinates); } - boost::optional - MakeGeometry(boost::optional> &&annotations) const + std::optional + MakeGeometry(std::optional> &&annotations) const { - boost::optional json_geometry; + std::optional json_geometry; if (annotations) { auto begin = annotations->begin(); @@ -720,8 +720,7 @@ class RouteAPI : public BaseAPI std::vector &leg_geometries = legs_info.second; auto route = guidance::assembleRoute(legs); - boost::optional json_overview = - MakeGeometry(MakeOverview(leg_geometries)); + std::optional json_overview = MakeGeometry(MakeOverview(leg_geometries)); std::vector step_geometries; const auto total_step_count = @@ -997,10 +996,10 @@ class RouteAPI : public BaseAPI return result; } - boost::optional> + std::optional> MakeOverview(const std::vector &leg_geometries) const { - boost::optional> overview; + std::optional> overview; if (parameters.overview != RouteParameters::OverviewType::False) { const auto use_simplification = diff --git a/include/engine/api/route_parameters.hpp b/include/engine/api/route_parameters.hpp index 267058a46bc..a28f34b8c7c 100644 --- a/include/engine/api/route_parameters.hpp +++ b/include/engine/api/route_parameters.hpp @@ -82,7 +82,7 @@ struct RouteParameters : public BaseParameters const bool alternatives_, const GeometriesType geometries_, const OverviewType overview_, - const boost::optional continue_straight_, + const std::optional continue_straight_, Args &&...args_) // Once we perfectly-forward `args` (see #2990) this constructor can delegate to the one // below. @@ -100,7 +100,7 @@ struct RouteParameters : public BaseParameters const bool annotations_, const GeometriesType geometries_, const OverviewType overview_, - const boost::optional continue_straight_, + const std::optional continue_straight_, Args &&...args_) : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_}, @@ -118,7 +118,7 @@ struct RouteParameters : public BaseParameters const AnnotationsType annotations_, const GeometriesType geometries_, const OverviewType overview_, - const boost::optional continue_straight_, + const std::optional continue_straight_, Args &&...args_) : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, number_of_alternatives{alternatives_ ? 1u : 0u}, @@ -135,7 +135,7 @@ struct RouteParameters : public BaseParameters const bool annotations_, const GeometriesType geometries_, const OverviewType overview_, - const boost::optional continue_straight_, + const std::optional continue_straight_, std::vector waypoints_, const Args &&...args_) : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, @@ -153,7 +153,7 @@ struct RouteParameters : public BaseParameters const AnnotationsType annotations_, const GeometriesType geometries_, const OverviewType overview_, - const boost::optional continue_straight_, + const std::optional continue_straight_, std::vector waypoints_, Args &&...args_) : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, @@ -172,7 +172,7 @@ struct RouteParameters : public BaseParameters AnnotationsType annotations_type = AnnotationsType::None; GeometriesType geometries = GeometriesType::Polyline; OverviewType overview = OverviewType::Simplified; - boost::optional continue_straight; + std::optional continue_straight; std::vector waypoints; bool IsValid() const diff --git a/include/engine/api/trip_parameters.hpp b/include/engine/api/trip_parameters.hpp index 7ad785ac097..cc3f4d938a2 100644 --- a/include/engine/api/trip_parameters.hpp +++ b/include/engine/api/trip_parameters.hpp @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "engine/api/route_parameters.hpp" -#include +#include #include namespace osrm::engine::api diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 7a495e86fe5..466c566942d 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -369,7 +369,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade std::vector NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const double max_distance, - const boost::optional bearing, + const std::optional bearing, const Approach approach, const bool use_all_edges) const override final { @@ -382,20 +382,20 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const size_t max_results, - const boost::optional max_distance, - const boost::optional bearing, + const std::optional max_distance, + const std::optional bearing, const Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodes( - input_coordinate, approach, max_results, max_distance, bearing, boost::none); + input_coordinate, approach, max_results, max_distance, bearing, std::nullopt); } PhantomCandidateAlternatives NearestCandidatesWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const boost::optional max_distance, - const boost::optional bearing, + const std::optional max_distance, + const std::optional bearing, const Approach approach, const bool use_all_edges) const override final { diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index 2d110e7dad2..ecf25577a33 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -126,21 +127,21 @@ class BaseDataFacade virtual std::vector NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const double max_distance, - const boost::optional bearing, + const std::optional bearing, const Approach approach, const bool use_all_edges) const = 0; virtual std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const size_t max_results, - const boost::optional max_distance, - const boost::optional bearing, + const std::optional max_distance, + const std::optional bearing, const Approach approach) const = 0; virtual PhantomCandidateAlternatives NearestCandidatesWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const boost::optional max_distance, - const boost::optional bearing, + const std::optional max_distance, + const std::optional bearing, const Approach approach, const bool use_all_edges) const = 0; diff --git a/include/engine/engine_config.hpp b/include/engine/engine_config.hpp index 439ec8aa6c0..e46f2c5e2ba 100644 --- a/include/engine/engine_config.hpp +++ b/include/engine/engine_config.hpp @@ -79,7 +79,7 @@ struct EngineConfig final int max_locations_map_matching = -1; double max_radius_map_matching = -1.0; int max_results_nearest = -1; - boost::optional default_radius = -1.0; + double default_radius = -1.0; int max_alternatives = 3; // set an arbitrary upper bound; can be adjusted by user bool use_shared_memory = true; std::filesystem::path memory_file; diff --git a/include/engine/geospatial_query.hpp b/include/engine/geospatial_query.hpp index c4efbcbbbe0..915dfec3e63 100644 --- a/include/engine/geospatial_query.hpp +++ b/include/engine/geospatial_query.hpp @@ -12,7 +12,7 @@ #include "osrm/coordinate.hpp" -#include +#include #include #include @@ -53,8 +53,8 @@ template class GeospatialQuery NearestPhantomNodes(const util::Coordinate input_coordinate, const Approach approach, const double max_distance, - const boost::optional bearing_with_range, - const boost::optional use_all_edges) const + const std::optional bearing_with_range, + const std::optional use_all_edges) const { auto results = rtree.SearchInRange( input_coordinate, @@ -85,9 +85,9 @@ template class GeospatialQuery NearestPhantomNodes(const util::Coordinate input_coordinate, const Approach approach, const size_t max_results, - const boost::optional max_distance, - const boost::optional bearing_with_range, - const boost::optional use_all_edges) const + const std::optional max_distance, + const std::optional bearing_with_range, + const std::optional use_all_edges) const { auto results = rtree.Nearest( input_coordinate, @@ -121,9 +121,9 @@ template class GeospatialQuery PhantomCandidateAlternatives NearestCandidatesWithAlternativeFromBigComponent( const util::Coordinate input_coordinate, const Approach approach, - const boost::optional max_distance, - const boost::optional bearing_with_range, - const boost::optional use_all_edges) const + const std::optional max_distance, + const std::optional bearing_with_range, + const std::optional use_all_edges) const { bool has_nearest = false; bool has_big_component = false; diff --git a/include/engine/guidance/assemble_steps.hpp b/include/engine/guidance/assemble_steps.hpp index b25b9976d6d..588e402b344 100644 --- a/include/engine/guidance/assemble_steps.hpp +++ b/include/engine/guidance/assemble_steps.hpp @@ -17,9 +17,9 @@ #include "util/guidance/turn_lanes.hpp" #include "util/typedefs.hpp" -#include #include #include +#include #include namespace osrm::engine::guidance diff --git a/include/engine/guidance/route_leg.hpp b/include/engine/guidance/route_leg.hpp index 681c4c40e7d..43149e4fcd1 100644 --- a/include/engine/guidance/route_leg.hpp +++ b/include/engine/guidance/route_leg.hpp @@ -3,7 +3,7 @@ #include "engine/guidance/route_step.hpp" -#include +#include #include #include diff --git a/include/engine/internal_route_result.hpp b/include/engine/internal_route_result.hpp index e2bc6f47553..78f5d11967d 100644 --- a/include/engine/internal_route_result.hpp +++ b/include/engine/internal_route_result.hpp @@ -15,7 +15,7 @@ #include "util/integer_range.hpp" #include "util/typedefs.hpp" -#include +#include #include namespace osrm::engine @@ -42,7 +42,7 @@ struct PathData // Source of the speed value on this road segment DatasourceID datasource_id; // If segment precedes a turn, ID of the turn itself - boost::optional turn_edge; + std::optional turn_edge; }; struct InternalRouteResult diff --git a/include/engine/plugins/match.hpp b/include/engine/plugins/match.hpp index d56be60fe0f..bfad1b7787d 100644 --- a/include/engine/plugins/match.hpp +++ b/include/engine/plugins/match.hpp @@ -22,7 +22,7 @@ class MatchPlugin : public BasePlugin MatchPlugin(const int max_locations_map_matching, const double max_radius_map_matching, - const boost::optional default_radius) + const std::optional default_radius) : BasePlugin(default_radius), max_locations_map_matching(max_locations_map_matching), max_radius_map_matching(max_radius_map_matching) { diff --git a/include/engine/plugins/nearest.hpp b/include/engine/plugins/nearest.hpp index 415639b2cc5..caa7463fd6a 100644 --- a/include/engine/plugins/nearest.hpp +++ b/include/engine/plugins/nearest.hpp @@ -13,7 +13,7 @@ namespace osrm::engine::plugins class NearestPlugin final : public BasePlugin { public: - explicit NearestPlugin(const int max_results, const boost::optional default_radius); + explicit NearestPlugin(const int max_results, const std::optional default_radius); Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::NearestParameters ¶ms, diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index 3a98022e98f..fbda1566413 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -29,7 +29,7 @@ class BasePlugin protected: BasePlugin() = default; - BasePlugin(const boost::optional default_radius_) : default_radius(default_radius_) {} + BasePlugin(const std::optional default_radius_) : default_radius(default_radius_) {} bool CheckAllCoordinates(const std::vector &coordinates) const { @@ -200,8 +200,8 @@ class BasePlugin phantom_nodes[i] = facade.NearestPhantomNodesInRange( parameters.coordinates[i], radiuses[i], - use_bearings ? parameters.bearings[i] : boost::none, - use_approaches && parameters.approaches[i] ? parameters.approaches[i].get() + use_bearings ? parameters.bearings[i] : std::nullopt, + use_approaches && parameters.approaches[i] ? parameters.approaches[i].value() : engine::Approach::UNRESTRICTED, use_all_edges); } @@ -242,8 +242,8 @@ class BasePlugin parameters.coordinates[i], number_of_results, use_radiuses ? parameters.radiuses[i] : default_radius, - use_bearings ? parameters.bearings[i] : boost::none, - use_approaches && parameters.approaches[i] ? parameters.approaches[i].get() + use_bearings ? parameters.bearings[i] : std::nullopt, + use_approaches && parameters.approaches[i] ? parameters.approaches[i].value() : engine::Approach::UNRESTRICTED); // we didn't find a fitting node, return error @@ -284,8 +284,8 @@ class BasePlugin alternatives[i] = facade.NearestCandidatesWithAlternativeFromBigComponent( parameters.coordinates[i], use_radiuses ? parameters.radiuses[i] : default_radius, - use_bearings ? parameters.bearings[i] : boost::none, - use_approaches && parameters.approaches[i] ? parameters.approaches[i].get() + use_bearings ? parameters.bearings[i] : std::nullopt, + use_approaches && parameters.approaches[i] ? parameters.approaches[i].value() : engine::Approach::UNRESTRICTED, use_all_edges); @@ -325,7 +325,7 @@ class BasePlugin std::to_string(missing_index); } - const boost::optional default_radius; + const std::optional default_radius; }; } // namespace osrm::engine::plugins diff --git a/include/engine/plugins/table.hpp b/include/engine/plugins/table.hpp index e4cf9a33ce2..9755cff3bdb 100644 --- a/include/engine/plugins/table.hpp +++ b/include/engine/plugins/table.hpp @@ -15,7 +15,7 @@ class TablePlugin final : public BasePlugin { public: explicit TablePlugin(const int max_locations_distance_table, - const boost::optional default_radius); + const std::optional default_radius); Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::TableParameters ¶ms, diff --git a/include/engine/plugins/trip.hpp b/include/engine/plugins/trip.hpp index 9cfdab09409..a08eaeed0d7 100644 --- a/include/engine/plugins/trip.hpp +++ b/include/engine/plugins/trip.hpp @@ -32,7 +32,7 @@ class TripPlugin final : public BasePlugin const bool roundtrip) const; public: - explicit TripPlugin(const int max_locations_trip_, boost::optional default_radius) + explicit TripPlugin(const int max_locations_trip_, std::optional default_radius) : BasePlugin(default_radius), max_locations_trip(max_locations_trip_) { } diff --git a/include/engine/plugins/viaroute.hpp b/include/engine/plugins/viaroute.hpp index e036ac90ecd..56040a58fe9 100644 --- a/include/engine/plugins/viaroute.hpp +++ b/include/engine/plugins/viaroute.hpp @@ -27,7 +27,7 @@ class ViaRoutePlugin final : public BasePlugin public: explicit ViaRoutePlugin(int max_locations_viaroute, int max_alternatives, - boost::optional default_radius); + std::optional default_radius); Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::RouteParameters &route_parameters, diff --git a/include/engine/routing_algorithms.hpp b/include/engine/routing_algorithms.hpp index 93c310a4a62..1be8020c4f0 100644 --- a/include/engine/routing_algorithms.hpp +++ b/include/engine/routing_algorithms.hpp @@ -25,7 +25,7 @@ class RoutingAlgorithmsInterface virtual InternalRouteResult ShortestPathSearch(const std::vector &waypoint_candidates, - const boost::optional continue_straight_at_waypoint) const = 0; + const std::optional continue_straight_at_waypoint) const = 0; virtual InternalRouteResult DirectShortestPathSearch(const PhantomEndpointCandidates &endpoint_candidates) const = 0; @@ -40,7 +40,7 @@ class RoutingAlgorithmsInterface MapMatching(const routing_algorithms::CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, + const std::vector> &trace_gps_precision, const bool allow_splitting) const = 0; virtual std::vector @@ -78,7 +78,7 @@ template class RoutingAlgorithms final : public RoutingAlgo InternalRouteResult ShortestPathSearch( const std::vector &waypoint_candidates, - const boost::optional continue_straight_at_waypoint) const final override; + const std::optional continue_straight_at_waypoint) const final override; InternalRouteResult DirectShortestPathSearch( const PhantomEndpointCandidates &endpoint_candidates) const final override; @@ -93,7 +93,7 @@ template class RoutingAlgorithms final : public RoutingAlgo MapMatching(const routing_algorithms::CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, + const std::vector> &trace_gps_precision, const bool allow_splitting) const final override; std::vector @@ -160,7 +160,7 @@ InternalManyRoutesResult RoutingAlgorithms::AlternativePathSearch( template InternalRouteResult RoutingAlgorithms::ShortestPathSearch( const std::vector &waypoint_candidates, - const boost::optional continue_straight_at_waypoint) const + const std::optional continue_straight_at_waypoint) const { return routing_algorithms::shortestPathSearch( heaps, *facade, waypoint_candidates, continue_straight_at_waypoint); @@ -178,7 +178,7 @@ inline routing_algorithms::SubMatchingList RoutingAlgorithms::MapMatc const routing_algorithms::CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, + const std::vector> &trace_gps_precision, const bool allow_splitting) const { return routing_algorithms::mapMatching(heaps, diff --git a/include/engine/routing_algorithms/map_matching.hpp b/include/engine/routing_algorithms/map_matching.hpp index c739aac996e..e9bcfac2630 100644 --- a/include/engine/routing_algorithms/map_matching.hpp +++ b/include/engine/routing_algorithms/map_matching.hpp @@ -24,7 +24,7 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, const CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, + const std::vector> &trace_gps_precision, const bool allow_splitting); } // namespace osrm::engine::routing_algorithms diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 0c61c1c37d2..d4dcdac5867 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -258,7 +258,7 @@ void annotatePath(const FacadeT &facade, alias_cast(duration_vector[segment_idx]), {0}, datasource_vector[segment_idx], - boost::none}); + std::nullopt}); } BOOST_ASSERT(!unpacked_path.empty()); @@ -315,7 +315,7 @@ void annotatePath(const FacadeT &facade, alias_cast(duration_vector[segment_idx]), {0}, datasource_vector[segment_idx], - boost::none}); + std::nullopt}); } if (!unpacked_path.empty()) diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index 00e85234ace..c9c24b939dd 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -14,7 +14,7 @@ InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, const std::vector &waypoint_candidates, - const boost::optional continue_straight_at_waypoint); + const std::optional continue_straight_at_waypoint); } // namespace osrm::engine::routing_algorithms diff --git a/include/engine/routing_algorithms/shortest_path_impl.hpp b/include/engine/routing_algorithms/shortest_path_impl.hpp index b9e74fd02e1..2cd3ccffb5f 100644 --- a/include/engine/routing_algorithms/shortest_path_impl.hpp +++ b/include/engine/routing_algorithms/shortest_path_impl.hpp @@ -4,7 +4,7 @@ #include "engine/routing_algorithms/shortest_path.hpp" #include -#include +#include namespace osrm::engine::routing_algorithms { @@ -339,10 +339,10 @@ struct leg_connections { // X_to_Y = i can be read as // sources[i].X is the source of the shortest leg path to target.Y - boost::optional forward_to_forward; - boost::optional reverse_to_forward; - boost::optional forward_to_reverse; - boost::optional reverse_to_reverse; + std::optional forward_to_forward; + std::optional reverse_to_forward; + std::optional forward_to_reverse; + std::optional reverse_to_reverse; }; // Identify which of the source candidates segments is being used for paths to the @@ -771,7 +771,7 @@ InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, const std::vector &waypoint_candidates, - const boost::optional continue_straight_at_waypoint) + const std::optional continue_straight_at_waypoint) { const bool allow_uturn_at_waypoint = !(continue_straight_at_waypoint ? *continue_straight_at_waypoint diff --git a/include/nodejs/node_osrm_support.hpp b/include/nodejs/node_osrm_support.hpp index cd0043bb4b6..f428308e50c 100644 --- a/include/nodejs/node_osrm_support.hpp +++ b/include/nodejs/node_osrm_support.hpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -395,11 +395,11 @@ inline engine_config_ptr argumentsToEngineConfig(const Napi::CallbackInfo &args) return engine_config; } -inline boost::optional> +inline std::optional> parseCoordinateArray(const Napi::Array &coordinates_array) { Napi::HandleScope scope(coordinates_array.Env()); - boost::optional> resulting_coordinates; + std::optional> resulting_coordinates; std::vector temp_coordinates; for (uint32_t i = 0; i < coordinates_array.Length(); ++i) @@ -450,7 +450,7 @@ parseCoordinateArray(const Napi::Array &coordinates_array) osrm::util::FloatLatitude{std::move(lat)}); } - resulting_coordinates = boost::make_optional(std::move(temp_coordinates)); + resulting_coordinates = std::make_optional(std::move(temp_coordinates)); return resulting_coordinates; } @@ -1023,7 +1023,7 @@ inline bool parseCommonParameters(const Napi::Object &obj, ParamType ¶ms) inline PluginParameters argumentsToPluginParameters( const Napi::CallbackInfo &args, - const boost::optional &output_format = {}) + const std::optional &output_format = {}) { if (args.Length() < 3 || !args[1].IsObject()) { diff --git a/include/server/api/base_parameters_grammar.hpp b/include/server/api/base_parameters_grammar.hpp index 80fda760bca..0891439e9a6 100644 --- a/include/server/api/base_parameters_grammar.hpp +++ b/include/server/api/base_parameters_grammar.hpp @@ -7,9 +7,9 @@ #include "engine/hint.hpp" #include "engine/polyline_compressor.hpp" -#include #include #include +#include #include #include @@ -88,7 +88,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar } else { - base_parameters.hints.emplace_back(boost::none); + base_parameters.hints.emplace_back(std::nullopt); } }; @@ -96,13 +96,24 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar [](engine::api::BaseParameters &base_parameters, boost::optional> bearing_range) { - boost::optional bearing; + std::optional bearing; if (bearing_range) { bearing = engine::Bearing{boost::fusion::at_c<0>(*bearing_range), boost::fusion::at_c<1>(*bearing_range)}; } - base_parameters.bearings.push_back(std::move(bearing)); + base_parameters.bearings.push_back(bearing); + }; + + const auto add_approach = [](engine::api::BaseParameters &base_parameters, + boost::optional approach) { + base_parameters.approaches.push_back(approach ? std::make_optional(*approach) + : std::nullopt); + }; + + const auto add_radius = [](engine::api::BaseParameters &base_parameters, + boost::optional radius) { + base_parameters.radiuses.push_back(radius ? std::make_optional(*radius) : std::nullopt); }; polyline_chars = qi::char_("a-zA-Z0-9_.--[]{}@?|\\%~`^"); @@ -144,9 +155,9 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar ((location_rule % ';') | polyline_rule | polyline6_rule)[ph::bind(&engine::api::BaseParameters::coordinates, qi::_r1) = qi::_1]; - radiuses_rule = qi::lit("radiuses=") > - (-(qi::double_ | unlimited_rule) % - ';')[ph::bind(&engine::api::BaseParameters::radiuses, qi::_r1) = qi::_1]; + radiuses_rule = + qi::lit("radiuses=") > + (-(qi::double_ | unlimited_rule))[ph::bind(add_radius, qi::_r1, qi::_1)] % ';'; hints_rule = qi::lit("hints=") > @@ -170,8 +181,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar "curb", engine::Approach::CURB)("opposite", engine::Approach::OPPOSITE); approach_rule = qi::lit("approaches=") > - (-approach_type % - ';')[ph::bind(&engine::api::BaseParameters::approaches, qi::_r1) = qi::_1]; + (-approach_type)[ph::bind(add_approach, qi::_r1, qi::_1)] % ';'; snapping_type.add("default", engine::api::BaseParameters::SnappingType::Default)( "any", engine::api::BaseParameters::SnappingType::Any); diff --git a/include/server/api/parameters_parser.hpp b/include/server/api/parameters_parser.hpp index db16ad77b3a..c6ee4edec12 100644 --- a/include/server/api/parameters_parser.hpp +++ b/include/server/api/parameters_parser.hpp @@ -26,13 +26,13 @@ using is_parameter_t = // Starts parsing and iter and modifies it until iter == end or parsing failed template ::value, int>::type = 0> -boost::optional parseParameters(std::string::iterator &iter, - const std::string::iterator end); +std::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end); // Copy on purpose because we need mutability template ::value, int>::type = 0> -boost::optional parseParameters(std::string options_string) +std::optional parseParameters(std::string options_string) { auto first = options_string.begin(); const auto last = options_string.end(); diff --git a/include/server/api/url_parser.hpp b/include/server/api/url_parser.hpp index 227fddfcb32..84c07bc7b53 100644 --- a/include/server/api/url_parser.hpp +++ b/include/server/api/url_parser.hpp @@ -3,7 +3,7 @@ #include "server/api/parsed_url.hpp" -#include +#include #include @@ -11,9 +11,9 @@ namespace osrm::server::api { // Starts parsing and iter and modifies it until iter == end or parsing failed -boost::optional parseURL(std::string::iterator &iter, const std::string::iterator end); +std::optional parseURL(std::string::iterator &iter, const std::string::iterator end); -inline boost::optional parseURL(std::string url_string) +inline std::optional parseURL(std::string url_string) { auto iter = url_string.begin(); return parseURL(iter, url_string.end()); diff --git a/src/benchmarks/bench.cpp b/src/benchmarks/bench.cpp index 39a941ed994..019ff645659 100644 --- a/src/benchmarks/bench.cpp +++ b/src/benchmarks/bench.cpp @@ -360,8 +360,8 @@ void runRouteBenchmark(const OSRM &osrm, const GPSTraces &gpsTraces, int iterati if (benchmark.radius) { - params.radiuses = std::vector>( - params.coordinates.size(), boost::make_optional(*benchmark.radius)); + params.radiuses = std::vector>( + params.coordinates.size(), std::make_optional(*benchmark.radius)); } engine::api::ResultT result = json::Object(); diff --git a/src/benchmarks/route.cpp b/src/benchmarks/route.cpp index e63a1039e4c..ada7a1d5e18 100644 --- a/src/benchmarks/route.cpp +++ b/src/benchmarks/route.cpp @@ -66,8 +66,8 @@ try if (benchmark.radius) { - params.radiuses = std::vector>( - params.coordinates.size(), boost::make_optional(*benchmark.radius)); + params.radiuses = std::vector>( + params.coordinates.size(), std::make_optional(*benchmark.radius)); } TIMER_START(routes); diff --git a/src/engine/api/json_factory.cpp b/src/engine/api/json_factory.cpp index 6765c935137..a17ea77994a 100644 --- a/src/engine/api/json_factory.cpp +++ b/src/engine/api/json_factory.cpp @@ -11,7 +11,7 @@ #include "util/typedefs.hpp" #include -#include +#include #include #include @@ -215,7 +215,7 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo util::json::Object makeRoute(const guidance::Route &route, util::json::Array legs, - boost::optional geometry, + std::optional geometry, const char *weight_name) { util::json::Object json_route; diff --git a/src/engine/engine_config.cpp b/src/engine/engine_config.cpp index bfe92841c63..ddc7651d4e9 100644 --- a/src/engine/engine_config.cpp +++ b/src/engine/engine_config.cpp @@ -12,15 +12,13 @@ bool EngineConfig::IsValid() const const auto unlimited_or_more_than = [](const auto v, const auto limit) { return v == -1 || v > limit; }; - const bool limits_valid = - unlimited_or_more_than(max_locations_distance_table, 2) && - unlimited_or_more_than(max_locations_map_matching, 2) && - unlimited_or_more_than(max_radius_map_matching, 0) && - unlimited_or_more_than(max_locations_trip, 2) && - unlimited_or_more_than(max_locations_viaroute, 2) && - unlimited_or_more_than(max_results_nearest, 0) && - (!default_radius.has_value() || unlimited_or_more_than(*default_radius, 0)) && - max_alternatives >= 0; + const bool limits_valid = unlimited_or_more_than(max_locations_distance_table, 2) && + unlimited_or_more_than(max_locations_map_matching, 2) && + unlimited_or_more_than(max_radius_map_matching, 0) && + unlimited_or_more_than(max_locations_trip, 2) && + unlimited_or_more_than(max_locations_viaroute, 2) && + unlimited_or_more_than(max_results_nearest, 0) && + unlimited_or_more_than(default_radius, 0) && max_alternatives >= 0; return ((use_shared_memory && all_path_are_empty) || (use_mmap && storage_config.IsValid()) || storage_config.IsValid()) && diff --git a/src/engine/plugins/match.cpp b/src/engine/plugins/match.cpp index fef9aac4e3f..6fe8f669996 100644 --- a/src/engine/plugins/match.cpp +++ b/src/engine/plugins/match.cpp @@ -194,7 +194,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, tidied.parameters.radiuses.begin(), tidied.parameters.radiuses.end(), search_radiuses.begin(), - [default_radius = this->default_radius](const boost::optional &maybe_radius) + [default_radius = this->default_radius](const std::optional &maybe_radius) { if (maybe_radius) { diff --git a/src/engine/plugins/nearest.cpp b/src/engine/plugins/nearest.cpp index 671dbe3f273..b8d43a5a6bd 100644 --- a/src/engine/plugins/nearest.cpp +++ b/src/engine/plugins/nearest.cpp @@ -10,7 +10,7 @@ namespace osrm::engine::plugins { -NearestPlugin::NearestPlugin(const int max_results_, const boost::optional default_radius_) +NearestPlugin::NearestPlugin(const int max_results_, const std::optional default_radius_) : BasePlugin(default_radius_), max_results{max_results_} { } diff --git a/src/engine/plugins/table.cpp b/src/engine/plugins/table.cpp index 4518113053b..5fd214c1a3f 100644 --- a/src/engine/plugins/table.cpp +++ b/src/engine/plugins/table.cpp @@ -15,7 +15,7 @@ namespace osrm::engine::plugins { TablePlugin::TablePlugin(const int max_locations_distance_table, - const boost::optional default_radius) + const std::optional default_radius) : BasePlugin(default_radius), max_locations_distance_table(max_locations_distance_table) { } diff --git a/src/engine/plugins/viaroute.cpp b/src/engine/plugins/viaroute.cpp index a8a1b2ee6f8..a59a2c467e0 100644 --- a/src/engine/plugins/viaroute.cpp +++ b/src/engine/plugins/viaroute.cpp @@ -17,7 +17,7 @@ namespace osrm::engine::plugins ViaRoutePlugin::ViaRoutePlugin(int max_locations_viaroute, int max_alternatives, - boost::optional default_radius) + std::optional default_radius) : BasePlugin(default_radius), max_locations_viaroute(max_locations_viaroute), max_alternatives(max_alternatives) { diff --git a/src/engine/routing_algorithms/map_matching.cpp b/src/engine/routing_algorithms/map_matching.cpp index 41f1f340585..45133551ef7 100644 --- a/src/engine/routing_algorithms/map_matching.cpp +++ b/src/engine/routing_algorithms/map_matching.cpp @@ -70,7 +70,7 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, const CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, + const std::vector> &trace_gps_precision, const bool allow_splitting) { map_matching::MatchingConfidence confidence; @@ -437,24 +437,22 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, } // CH -template SubMatchingList -mapMatching(SearchEngineData &engine_working_data, - const DataFacade &facade, - const CandidateLists &candidates_list, - const std::vector &trace_coordinates, - const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, - const bool allow_splitting); +template SubMatchingList mapMatching(SearchEngineData &engine_working_data, + const DataFacade &facade, + const CandidateLists &candidates_list, + const std::vector &trace_coordinates, + const std::vector &trace_timestamps, + const std::vector> &trace_gps_precision, + const bool allow_splitting); // MLD -template SubMatchingList -mapMatching(SearchEngineData &engine_working_data, - const DataFacade &facade, - const CandidateLists &candidates_list, - const std::vector &trace_coordinates, - const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, - const bool allow_splitting); +template SubMatchingList mapMatching(SearchEngineData &engine_working_data, + const DataFacade &facade, + const CandidateLists &candidates_list, + const std::vector &trace_coordinates, + const std::vector &trace_timestamps, + const std::vector> &trace_gps_precision, + const bool allow_splitting); } // namespace osrm::engine::routing_algorithms diff --git a/src/engine/routing_algorithms/shortest_path.cpp b/src/engine/routing_algorithms/shortest_path.cpp index fc34810661e..36899631a3b 100644 --- a/src/engine/routing_algorithms/shortest_path.cpp +++ b/src/engine/routing_algorithms/shortest_path.cpp @@ -9,12 +9,12 @@ template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, const std::vector &waypoint_candidates, - const boost::optional continue_straight_at_waypoint); + const std::optional continue_straight_at_waypoint); template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, const std::vector &waypoint_candidates, - const boost::optional continue_straight_at_waypoint); + const std::optional continue_straight_at_waypoint); } // namespace osrm::engine::routing_algorithms diff --git a/src/server/api/parameters_parser.cpp b/src/server/api/parameters_parser.cpp index 7d3db1d16bc..8e3f5027013 100644 --- a/src/server/api/parameters_parser.cpp +++ b/src/server/api/parameters_parser.cpp @@ -28,8 +28,8 @@ template ::value, int>::type = 0, typename std::enable_if::value, int>::type = 0> -boost::optional parseParameters(std::string::iterator &iter, - const std::string::iterator end) +std::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { using It = std::decay::type; @@ -56,52 +56,52 @@ boost::optional parseParameters(std::string::iterator &iter, // as normal parser error } - return boost::none; + return std::nullopt; } } // namespace detail template <> -boost::optional parseParameters(std::string::iterator &iter, - const std::string::iterator end) +std::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { return detail::parseParameters>(iter, end); } template <> -boost::optional parseParameters(std::string::iterator &iter, - const std::string::iterator end) +std::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { return detail::parseParameters>(iter, end); } template <> -boost::optional parseParameters(std::string::iterator &iter, - const std::string::iterator end) +std::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { return detail::parseParameters>(iter, end); } template <> -boost::optional parseParameters(std::string::iterator &iter, - const std::string::iterator end) +std::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { return detail::parseParameters>(iter, end); } template <> -boost::optional parseParameters(std::string::iterator &iter, - const std::string::iterator end) +std::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { return detail::parseParameters>(iter, end); } template <> -boost::optional parseParameters(std::string::iterator &iter, - const std::string::iterator end) +std::optional parseParameters(std::string::iterator &iter, + const std::string::iterator end) { return detail::parseParameters>(iter, end); } diff --git a/src/server/api/url_parser.cpp b/src/server/api/url_parser.cpp index a7323d30846..c870e512ee5 100644 --- a/src/server/api/url_parser.cpp +++ b/src/server/api/url_parser.cpp @@ -65,7 +65,7 @@ struct URLParser final : qi::grammar namespace osrm::server::api { -boost::optional parseURL(std::string::iterator &iter, const std::string::iterator end) +std::optional parseURL(std::string::iterator &iter, const std::string::iterator end) { using It = std::decay::type; @@ -77,7 +77,7 @@ boost::optional parseURL(std::string::iterator &iter, const std::stri const auto ok = boost::spirit::qi::parse(iter, end, parser(boost::phoenix::val(iter)), out); if (ok && iter == end) - return boost::make_optional(out); + return std::make_optional(out); } catch (const qi::expectation_failure &failure) { @@ -86,7 +86,7 @@ boost::optional parseURL(std::string::iterator &iter, const std::stri iter = failure.first; } - return boost::none; + return std::nullopt; } } // namespace osrm::server::api diff --git a/src/tools/routed.cpp b/src/tools/routed.cpp index 07dcf864c06..8c35413f677 100644 --- a/src/tools/routed.cpp +++ b/src/tools/routed.cpp @@ -186,7 +186,7 @@ inline unsigned generateServerProgramOptions(const int argc, value(&config.max_radius_map_matching)->default_value(-1.0), "Max. radius size supported in map matching query. Default: unlimited.") // ("default-radius", - value>(&config.default_radius)->default_value(-1.0), + value(&config.default_radius)->default_value(-1.0), "Default radius size for queries. Default: unlimited."); // hidden options, will be allowed on command line, but will not be shown to the user diff --git a/unit_tests/engine/collapse_internal_route_result.cpp b/unit_tests/engine/collapse_internal_route_result.cpp index 6d00e12d10f..982055279a0 100644 --- a/unit_tests/engine/collapse_internal_route_result.cpp +++ b/unit_tests/engine/collapse_internal_route_result.cpp @@ -19,8 +19,8 @@ BOOST_AUTO_TEST_CASE(unchanged_collapse_route_result) PhantomNode target; source.forward_segment_id = {1, true}; target.forward_segment_id = {6, true}; - PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, boost::none}; - PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, boost::none}; + PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, std::nullopt}; + PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, std::nullopt}; InternalRouteResult one_leg_result; one_leg_result.unpacked_path_segments = {{pathy, kathy}}; one_leg_result.leg_endpoints = {PhantomEndpoints{source, target}}; @@ -39,9 +39,9 @@ BOOST_AUTO_TEST_CASE(two_legs_to_one_leg) { // from_edge_based_node, turn_via_node, weight_until_turn, weight_of_turn, // duration_until_turn, duration_of_turn, datasource_id, turn_edge - PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, boost::none}; - PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, boost::none}; - PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, boost::none}; + PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, std::nullopt}; + PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, std::nullopt}; + PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, std::nullopt}; PhantomNode node_1; PhantomNode node_2; PhantomNode node_3; @@ -74,11 +74,11 @@ BOOST_AUTO_TEST_CASE(two_legs_to_one_leg) BOOST_AUTO_TEST_CASE(three_legs_to_two_legs) { - PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, boost::none}; - PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, boost::none}; - PathData qathy{0, 5, {1}, {2}, {3}, {4}, 1, boost::none}; - PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, boost::none}; - PathData mathy{0, 4, {8}, {9}, {13}, {4}, 2, boost::none}; + PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, std::nullopt}; + PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, std::nullopt}; + PathData qathy{0, 5, {1}, {2}, {3}, {4}, 1, std::nullopt}; + PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, std::nullopt}; + PathData mathy{0, 4, {8}, {9}, {13}, {4}, 2, std::nullopt}; PhantomNode node_1; PhantomNode node_2; PhantomNode node_3; @@ -131,9 +131,9 @@ BOOST_AUTO_TEST_CASE(three_legs_to_two_legs) BOOST_AUTO_TEST_CASE(two_legs_to_two_legs) { - PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, boost::none}; - PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, boost::none}; - PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, boost::none}; + PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, std::nullopt}; + PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, std::nullopt}; + PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, std::nullopt}; PhantomNode node_1; PhantomNode node_2; PhantomNode node_3; diff --git a/unit_tests/engine/offline_facade.cpp b/unit_tests/engine/offline_facade.cpp index 822d02f4fe6..ae9307e1acc 100644 --- a/unit_tests/engine/offline_facade.cpp +++ b/unit_tests/engine/offline_facade.cpp @@ -219,7 +219,7 @@ class ContiguousInternalMemoryDataFacade std::vector NearestPhantomNodesInRange(const util::Coordinate /*input_coordinate*/, const double /*max_distance*/, - const boost::optional /*bearing*/, + const std::optional /*bearing*/, const engine::Approach /*approach*/, const bool /*use_all_edges*/) const override { @@ -229,8 +229,8 @@ class ContiguousInternalMemoryDataFacade std::vector NearestPhantomNodes(const util::Coordinate /*input_coordinate*/, const size_t /*max_results*/, - const boost::optional /*max_distance*/, - const boost::optional /*bearing*/, + const std::optional /*max_distance*/, + const std::optional /*bearing*/, const engine::Approach /*approach*/) const override { return {}; @@ -238,8 +238,8 @@ class ContiguousInternalMemoryDataFacade engine::PhantomCandidateAlternatives NearestCandidatesWithAlternativeFromBigComponent( const util::Coordinate /*input_coordinate*/, - const boost::optional /*max_distance*/, - const boost::optional /*bearing*/, + const std::optional /*max_distance*/, + const std::optional /*bearing*/, const engine::Approach /*approach*/, const bool /*use_all_edges*/) const override { diff --git a/unit_tests/library/table.cpp b/unit_tests/library/table.cpp index e1caafdae25..c29d58f549a 100644 --- a/unit_tests/library/table.cpp +++ b/unit_tests/library/table.cpp @@ -271,8 +271,8 @@ void test_table_no_segment_for_some_coordinates(bool use_json_only_api) params.coordinates.push_back(get_dummy_location()); params.coordinates.push_back(get_dummy_location()); // resembles query option: `&radiuses=0;` - params.radiuses.push_back(boost::make_optional(0.)); - params.radiuses.push_back(boost::none); + params.radiuses.push_back(std::make_optional(0.)); + params.radiuses.push_back(std::nullopt); json::Object json_result; const auto rc = run_table_json(osrm, params, json_result, use_json_only_api); diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp index dc2541713e5..45e9c87f270 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -107,7 +107,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade std::vector NearestPhantomNodesInRange(const util::Coordinate /*input_coordinate*/, const double /*max_distance*/, - const boost::optional /*bearing*/, + const std::optional /*bearing*/, const engine::Approach /*approach*/, const bool /*use_all_edges*/) const override { @@ -117,8 +117,8 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade std::vector NearestPhantomNodes(const util::Coordinate /*input_coordinate*/, const size_t /*max_results*/, - const boost::optional /*max_distance*/, - const boost::optional /*bearing*/, + const std::optional /*max_distance*/, + const std::optional /*bearing*/, const engine::Approach /*approach*/) const override { return {}; @@ -126,8 +126,8 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade engine::PhantomCandidateAlternatives NearestCandidatesWithAlternativeFromBigComponent( const util::Coordinate /*input_coordinate*/, - const boost::optional /*max_distance*/, - const boost::optional /*bearing*/, + const std::optional /*max_distance*/, + const std::optional /*bearing*/, const engine::Approach /*approach*/, const bool /*use_all_edges*/) const override { diff --git a/unit_tests/server/parameters_parser.cpp b/unit_tests/server/parameters_parser.cpp index 22b03f6fd15..fee69f8b282 100644 --- a/unit_tests/server/parameters_parser.cpp +++ b/unit_tests/server/parameters_parser.cpp @@ -32,6 +32,11 @@ (R2)[i]->segment_hints.end()); \ } \ } +// TODO: we should be able to somehow make Boost.Test to print std::optional types +BOOST_TEST_DONT_PRINT_LOG_VALUE(std::optional) +BOOST_TEST_DONT_PRINT_LOG_VALUE(std::optional) +BOOST_TEST_DONT_PRINT_LOG_VALUE(std::optional) +BOOST_TEST_DONT_PRINT_LOG_VALUE(std::optional) BOOST_AUTO_TEST_SUITE(api_parameters_parser) @@ -216,7 +221,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) phantom_1.input_location = coords_1[0]; engine::PhantomNode phantom_2; phantom_2.input_location = coords_1[1]; - std::vector> hints_4 = { + std::vector> hints_4 = { engine::Hint{{engine::SegmentHint{phantom_1, 0x1337}}}, engine::Hint{{engine::SegmentHint{phantom_2, 0x1337}}}}; RouteParameters reference_4{false, @@ -224,11 +229,11 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) false, RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, - boost::optional{}, + std::optional{}, coords_1, hints_4, - std::vector>{}, - std::vector>{}}; + std::vector>{}, + std::vector>{}}; auto result_4 = parseParameters( "1,2;3,4?steps=false&hints=" + hints_4[0]->ToBase64() + ";" + hints_4[1]->ToBase64()); BOOST_CHECK(result_4); @@ -244,8 +249,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) CHECK_EQUAL_RANGE(reference_4.coordinates, result_4->coordinates); CHECK_EQUAL_RANGE_OF_HINTS(reference_4.hints, result_4->hints); - std::vector> bearings_4 = { - boost::none, + std::vector> bearings_4 = { + std::nullopt, engine::Bearing{200, 10}, engine::Bearing{100, 5}, }; @@ -254,10 +259,10 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) false, RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, - boost::optional{}, + std::optional{}, coords_1, - std::vector>{}, - std::vector>{}, + std::vector>{}, + std::vector>{}, bearings_4}; auto result_5 = parseParameters("1,2;3,4?steps=false&bearings=;200,10;100,5"); BOOST_CHECK(result_5); @@ -296,8 +301,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) auto result_7 = parseParameters("1,2;3,4?radiuses=;unlimited"); RouteParameters reference_7{}; reference_7.coordinates = coords_1; - reference_7.radiuses = {boost::none, - boost::make_optional(std::numeric_limits::infinity())}; + reference_7.radiuses = {std::nullopt, + std::make_optional(std::numeric_limits::infinity())}; BOOST_CHECK(result_7); BOOST_CHECK_EQUAL(reference_7.steps, result_7->steps); BOOST_CHECK_EQUAL(reference_7.alternatives, result_7->alternatives); @@ -314,14 +319,14 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) auto result_8 = parseParameters("1,2;3,4?radiuses=;"); RouteParameters reference_8{}; reference_8.coordinates = coords_1; - reference_8.radiuses = {boost::none, boost::none}; + reference_8.radiuses = {std::nullopt, std::nullopt}; BOOST_CHECK(result_8); CHECK_EQUAL_RANGE(reference_8.radiuses, result_8->radiuses); auto result_9 = parseParameters("1,2?radiuses="); RouteParameters reference_9{}; reference_9.coordinates = coords_1; - reference_9.radiuses = {boost::none}; + reference_9.radiuses = {std::nullopt}; BOOST_CHECK(result_9); CHECK_EQUAL_RANGE(reference_9.radiuses, result_9->radiuses); @@ -335,7 +340,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) phantom_3.input_location = coords_3[0]; engine::PhantomNode phantom_4; phantom_4.input_location = coords_3[2]; - std::vector> hints_10 = { + std::vector> hints_10 = { engine::Hint{{engine::SegmentHint{phantom_3, 0x1337}}}, {}, engine::Hint{{engine::SegmentHint{phantom_4, 0x1337}}}, @@ -346,11 +351,11 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) false, RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, - boost::optional{}, + std::optional{}, coords_3, hints_10, - std::vector>{}, - std::vector>{}}; + std::vector>{}, + std::vector>{}}; auto result_10 = parseParameters( "1,2;3,4;5,6;7,8?steps=false&hints=" + hints_10[0]->ToBase64() + ";;" + hints_10[2]->ToBase64() + ";"); @@ -447,8 +452,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(result_2->annotations_type == RouteParameters::AnnotationsType::All, true); BOOST_CHECK_EQUAL(result_17->annotations, true); - std::vector> approaches_18 = { - boost::none, + std::vector> approaches_18 = { + std::nullopt, engine::Approach::CURB, engine::Approach::UNRESTRICTED, engine::Approach::OPPOSITE, @@ -458,11 +463,11 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) false, RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, - boost::optional{}, + std::optional{}, coords_3, - std::vector>{}, - std::vector>{}, - std::vector>{}, + std::vector>{}, + std::vector>{}, + std::vector>{}, approaches_18}; auto result_18 = parseParameters( @@ -778,6 +783,7 @@ BOOST_AUTO_TEST_CASE(valid_trip_urls) reference_1.coordinates = coords_1; auto result_1 = parseParameters("1,2;3,4"); BOOST_CHECK(result_1); + CHECK_EQUAL_RANGE(reference_1.radiuses, result_1->radiuses); CHECK_EQUAL_RANGE(reference_1.coordinates, result_1->coordinates); diff --git a/unit_tests/util/static_rtree.cpp b/unit_tests/util/static_rtree.cpp index d2e29fa2eea..06c75343215 100644 --- a/unit_tests/util/static_rtree.cpp +++ b/unit_tests/util/static_rtree.cpp @@ -332,13 +332,13 @@ BOOST_AUTO_TEST_CASE(radius_regression_test) { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 0.01, boost::none, true); + input, osrm::engine::Approach::UNRESTRICTED, 0.01, std::nullopt, true); BOOST_CHECK_EQUAL(results.size(), 0); } { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 1, 0.01, boost::none, true); + input, osrm::engine::Approach::UNRESTRICTED, 1, 0.01, std::nullopt, true); BOOST_CHECK_EQUAL(results.size(), 0); } } @@ -364,25 +364,25 @@ BOOST_AUTO_TEST_CASE(permissive_edge_snapping) { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 1000, boost::none, false); + input, osrm::engine::Approach::UNRESTRICTED, 1000, std::nullopt, false); BOOST_CHECK_EQUAL(results.size(), 1); } { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 1000, boost::none, true); + input, osrm::engine::Approach::UNRESTRICTED, 1000, std::nullopt, true); BOOST_CHECK_EQUAL(results.size(), 2); } { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 10, 1000, boost::none, false); + input, osrm::engine::Approach::UNRESTRICTED, 10, 1000, std::nullopt, false); BOOST_CHECK_EQUAL(results.size(), 1); } { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 10, 1000, boost::none, true); + input, osrm::engine::Approach::UNRESTRICTED, 10, 1000, std::nullopt, true); BOOST_CHECK_EQUAL(results.size(), 2); } } @@ -408,7 +408,7 @@ BOOST_AUTO_TEST_CASE(bearing_tests) { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 5, boost::none, boost::none, false); + input, osrm::engine::Approach::UNRESTRICTED, 5, std::nullopt, std::nullopt, false); BOOST_CHECK_EQUAL(results.size(), 2); BOOST_CHECK_EQUAL(results.back().phantom_node.forward_segment_id.id, 0); BOOST_CHECK_EQUAL(results.back().phantom_node.reverse_segment_id.id, 1); @@ -418,7 +418,7 @@ BOOST_AUTO_TEST_CASE(bearing_tests) auto results = query.NearestPhantomNodes(input, osrm::engine::Approach::UNRESTRICTED, 5, - boost::none, + std::nullopt, engine::Bearing{270, 10}, false); BOOST_CHECK_EQUAL(results.size(), 0); @@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(bearing_tests) auto results = query.NearestPhantomNodes(input, osrm::engine::Approach::UNRESTRICTED, 5, - boost::none, + std::nullopt, engine::Bearing{45, 10}, false); BOOST_CHECK_EQUAL(results.size(), 2); @@ -444,13 +444,13 @@ BOOST_AUTO_TEST_CASE(bearing_tests) { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 11000, boost::none, true); + input, osrm::engine::Approach::UNRESTRICTED, 11000, std::nullopt, true); BOOST_CHECK_EQUAL(results.size(), 2); } { auto results = query.NearestPhantomNodes( - input, osrm::engine::Approach::UNRESTRICTED, 10, 11000, boost::none, true); + input, osrm::engine::Approach::UNRESTRICTED, 10, 11000, std::nullopt, true); BOOST_CHECK_EQUAL(results.size(), 2); }