Loading...
Searching...
No Matches
tf::HasGraph Concept Reference

concept that determines if a type owns or provides access to a tf::Graph More...

#include <taskflow/core/graph.hpp>

Concept definition

template<typename T>
concept tf::HasGraph = std::derived_from<T, Graph> ||
requires(T& t) {
{ t.graph() } -> std::convertible_to<Graph&>;
}
concept that determines if a type owns or provides access to a tf::Graph
Definition graph.hpp:1014

Detailed Description

concept that determines if a type owns or provides access to a tf::Graph

A type satisfies tf::HasGraph if it meets one of the following two criteria:

  • Inheritance: The type is derived from tf::Graph.
  • Composition: The type provides a graph() method that returns a reference convertible to tf::Graph&.

This concept is used by tf::retrieve_graph to abstract the way graphs are accessed across different taskflow components.

// Satisfies via inheritance
struct CustomGraph1 : public tf::Graph {};
// Satisfies via composition
struct CustomGraph2 {
tf::Graph& graph() { return _g; }
};
// Fails: does not meet inheritance or method requirements
struct InvalidType {
void handle() {}
};
static_assert(!tf::HasGraph<InvalidType>);
class to create a graph object
Definition graph.hpp:47