template<typename C>
std::same_as<std::invoke_result_t<C, tf::Subflow&>, void>
determines if a callable is a subflow task
Definition task.hpp:220
determines if a callable is a subflow task
A subflow task is a callable object that takes a tf::Subflow& reference and returns void. Subflow tasks allow dynamic creation of nested tasks at runtime. It is constructible from std::function<void(tf::Subflow&)>.
- Requirements
- Must be invocable with a tf::Subflow& argument
- Must return void
- Examples
auto task1 = sf.emplace([]() { std::cout << "subtask 1\n"; });
auto task2 = sf.emplace([]() { std::cout << "subtask 2\n"; });
task1.precede(task2);
};
static_assert(SubflowTaskLike<decltype(subflow_task)>);
int num_tasks = 5;
for(int i = 0; i < num_tasks; ++i) {
sf.emplace([i]() { std::cout << "task " << i << '\n'; });
}
};
static_assert(SubflowTaskLike<decltype(dynamic_subflow)>);
struct SubflowTask {
void operator()(tf::Subflow& sf) const {
sf.
emplace([]() { std::cout <<
"nested\n"; });
}
};
static_assert(SubflowTaskLike<SubflowTask>);
auto task = taskflow.
emplace(subflow_task).
name(
"subflow");
Task emplace(C &&callable)
creates a static task
Definition flow_builder.hpp:1562
class to construct a subflow graph from the execution of a dynamic task
Definition flow_builder.hpp:1726
const std::string & name() const
queries the name of the task
Definition task.hpp:1388
class to create a taskflow object
Definition taskflow.hpp:64
- Invalid Examples
auto not_subflow1 = []() { std::cout << "no params\n"; };
auto not_subflow2 = [](int x) { std::cout << x << '\n'; };
auto not_subflow3 = [](
tf::Subflow& sf) {
return 42; };