Skip to content

Commit

Permalink
Fix C++17 build
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Jan 10, 2024
1 parent bd241ab commit fe19f3c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ortools/graph/dag_constrained_shortest_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ PathWithLength ConstrainedShortestPathsOnDag(
// -----------------------------------------------------------------------------
// Advanced API.
// -----------------------------------------------------------------------------
#if __cplusplus >= 202002L
template <class GraphType>
concept DagGraphType = requires(GraphType graph) {
{ typename GraphType::NodeIndex{} };
Expand All @@ -81,16 +82,19 @@ concept DagGraphType = requires(GraphType graph) {
graph.Head(typename GraphType::ArcIndex{})
} -> std::same_as<typename GraphType::NodeIndex>;
};
#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 <class GraphType>
#if __cplusplus >= 202002L
requires DagGraphType<GraphType>
#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.
//
Expand Down Expand Up @@ -198,7 +202,9 @@ std::vector<int> GetInversePermutation(absl::Span<const int> permutation);
// -----------------------------------------------------------------------------

template <class GraphType>
#if __cplusplus >= 202002L
requires DagGraphType<GraphType>
#endif
ConstrainedShortestPathsOnDagWrapper<GraphType>::
ConstrainedShortestPathsOnDagWrapper(
const GraphType* graph, const std::vector<double>* arc_lengths,
Expand Down Expand Up @@ -285,7 +291,9 @@ ConstrainedShortestPathsOnDagWrapper<GraphType>::
}

template <typename GraphType>
#if __cplusplus >= 202002L
requires DagGraphType<GraphType>
#endif
double ConstrainedShortestPathsOnDagWrapper<GraphType>::LengthTo(
NodeIndex node) const {
CHECK(IsReachable(node));
Expand All @@ -300,7 +308,9 @@ double ConstrainedShortestPathsOnDagWrapper<GraphType>::LengthTo(
}

template <typename GraphType>
#if __cplusplus >= 202002L
requires DagGraphType<GraphType>
#endif
bool ConstrainedShortestPathsOnDagWrapper<GraphType>::Label::IsLinkedTo(
const Label& other, ArcIndex arc, const std::vector<double>* arc_lengths,
const std::vector<std::vector<double>>* arc_resources) const {
Expand All @@ -316,7 +326,9 @@ bool ConstrainedShortestPathsOnDagWrapper<GraphType>::Label::IsLinkedTo(
}

template <typename GraphType>
#if __cplusplus >= 202002L
requires DagGraphType<GraphType>
#endif
std::vector<typename GraphType::ArcIndex>
ConstrainedShortestPathsOnDagWrapper<GraphType>::ArcPathTo(
NodeIndex node) const {
Expand Down Expand Up @@ -348,7 +360,9 @@ ConstrainedShortestPathsOnDagWrapper<GraphType>::ArcPathTo(
}

template <typename GraphType>
#if __cplusplus >= 202002L
requires DagGraphType<GraphType>
#endif
std::vector<typename GraphType::NodeIndex>
ConstrainedShortestPathsOnDagWrapper<GraphType>::NodePathTo(
NodeIndex node) const {
Expand Down Expand Up @@ -381,7 +395,9 @@ ConstrainedShortestPathsOnDagWrapper<GraphType>::NodePathTo(
}

template <class GraphType>
#if __cplusplus >= 202002L
requires DagGraphType<GraphType>
#endif
void ConstrainedShortestPathsOnDagWrapper<
GraphType>::RunConstrainedShortestPathOnDag() {
// Caching the vector addresses allow to not fetch it on each access.
Expand Down

0 comments on commit fe19f3c

Please sign in to comment.