chore: C++20 RoutingAlgorithm concept#7529
Open
DennisOSRM wants to merge 2 commits intomasterfrom
Open
Conversation
Add include/engine/concepts.hpp and constrain templates (RoutingAlgorithms, SearchEngineData, Engine) using the RoutingAlgorithm concept. This is a proof-of-concept to document and enforce the compile-time interface required by algorithm marker types and to enable incremental migration from TMP to C++20 concepts. Build/test: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug && cmake --build build -j4 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a C++20 RoutingAlgorithm concept and applies it to constrain key engine templates, with the goal of making compile-time expectations explicit and starting a migration away from TMP/SFINAE-style constraints.
Changes:
- Added
include/engine/concepts.hppdefiningrouting_algorithms::RoutingAlgorithm. - Constrained
SearchEngineData,RoutingAlgorithms, andEnginetemplates toRoutingAlgorithm. - Updated relevant headers to include the new concepts header where needed.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| include/engine/concepts.hpp | Adds the new RoutingAlgorithm concept describing/validating the expected algorithm marker-type interface. |
| include/engine/routing_algorithms.hpp | Constrains RoutingAlgorithms and its out-of-class definitions to the concept. |
| include/engine/search_engine_data.hpp | Constrains SearchEngineData primary template to the concept. |
| include/engine/engine.hpp | Constrains Engine to the concept. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+32
to
+37
| template <typename T> | ||
| concept RoutingAlgorithm = requires { | ||
| /* name() and identifier() are callable and return C strings */ | ||
| { name<T>() } -> std::convertible_to<const char *>; | ||
| { identifier<T>() } -> std::convertible_to<const char *>; | ||
|
|
|
|
||
| #include "engine/algorithm.hpp" | ||
| #include <concepts> | ||
| #include <type_traits> |
Comment on lines
40
to
+42
|
|
||
| template <typename Algorithm> class Engine final : public EngineInterface | ||
| template <routing_algorithms::RoutingAlgorithm Algorithm> | ||
| class Engine final : public EngineInterface |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This draft PR introduces a C++20 RoutingAlgorithm concept and constrains core templates (RoutingAlgorithms, SearchEngineData, Engine) to it.
Motivation:
Changes:
Testing:
Notes: