| Taskflow: A General-purpose Task-parallel Programming System

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

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

`#include <taskflow/core/graph.hpp>`

## Concept definition

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

## Detailed Description

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

A type satisfies `tf::GraphLike` 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 {};
static_assert(tf::GraphLike<CustomGraph1>);
// Satisfies via composition
struct CustomGraph2 {
tf::Graph& graph() { return _g; }
tf::Graph _g;
};
static_assert(tf::GraphLike<CustomGraph2>);
// Fails: does not meet inheritance or method requirements
struct InvalidType {
void handle() {}
};
static_assert(!tf::GraphLike<InvalidType>);
tf::Graph
class to create a graph object
Definition graph.hpp:47