From fe19f3c22ad33e193e7b7fd41ffa6282ee5739ff Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Wed, 10 Jan 2024 11:30:20 +0100 Subject: [PATCH] Fix C++17 build --- ortools/graph/dag_constrained_shortest_path.h | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ortools/graph/dag_constrained_shortest_path.h b/ortools/graph/dag_constrained_shortest_path.h index 19cc302f21e..cf41d0463ca 100644 --- a/ortools/graph/dag_constrained_shortest_path.h +++ b/ortools/graph/dag_constrained_shortest_path.h @@ -67,6 +67,7 @@ PathWithLength ConstrainedShortestPathsOnDag( // ----------------------------------------------------------------------------- // Advanced API. // ----------------------------------------------------------------------------- +#if __cplusplus >= 202002L template concept DagGraphType = requires(GraphType graph) { { typename GraphType::NodeIndex{} }; @@ -81,16 +82,19 @@ concept DagGraphType = requires(GraphType graph) { graph.Head(typename GraphType::ArcIndex{}) } -> std::same_as; }; +#endif // A wrapper that holds the memory needed to run many constrained shortest path // computations efficiently on the given DAG (on which resources do not change). // `GraphType` can use one of the interfaces defined in `util/graph/graph.h`. template +#if __cplusplus >= 202002L requires DagGraphType +#endif class ConstrainedShortestPathsOnDagWrapper { public: - using NodeIndex = GraphType::NodeIndex; - using ArcIndex = GraphType::ArcIndex; + using NodeIndex = typename GraphType::NodeIndex; + using ArcIndex = typename GraphType::ArcIndex; // IMPORTANT: All arguments must outlive the class. // @@ -198,7 +202,9 @@ std::vector GetInversePermutation(absl::Span permutation); // ----------------------------------------------------------------------------- template +#if __cplusplus >= 202002L requires DagGraphType +#endif ConstrainedShortestPathsOnDagWrapper:: ConstrainedShortestPathsOnDagWrapper( const GraphType* graph, const std::vector* arc_lengths, @@ -285,7 +291,9 @@ ConstrainedShortestPathsOnDagWrapper:: } template +#if __cplusplus >= 202002L requires DagGraphType +#endif double ConstrainedShortestPathsOnDagWrapper::LengthTo( NodeIndex node) const { CHECK(IsReachable(node)); @@ -300,7 +308,9 @@ double ConstrainedShortestPathsOnDagWrapper::LengthTo( } template +#if __cplusplus >= 202002L requires DagGraphType +#endif bool ConstrainedShortestPathsOnDagWrapper::Label::IsLinkedTo( const Label& other, ArcIndex arc, const std::vector* arc_lengths, const std::vector>* arc_resources) const { @@ -316,7 +326,9 @@ bool ConstrainedShortestPathsOnDagWrapper::Label::IsLinkedTo( } template +#if __cplusplus >= 202002L requires DagGraphType +#endif std::vector ConstrainedShortestPathsOnDagWrapper::ArcPathTo( NodeIndex node) const { @@ -348,7 +360,9 @@ ConstrainedShortestPathsOnDagWrapper::ArcPathTo( } template +#if __cplusplus >= 202002L requires DagGraphType +#endif std::vector ConstrainedShortestPathsOnDagWrapper::NodePathTo( NodeIndex node) const { @@ -381,7 +395,9 @@ ConstrainedShortestPathsOnDagWrapper::NodePathTo( } template +#if __cplusplus >= 202002L requires DagGraphType +#endif void ConstrainedShortestPathsOnDagWrapper< GraphType>::RunConstrainedShortestPathOnDag() { // Caching the vector addresses allow to not fetch it on each access.