determines if a callable is a multi-condition task
A multi-condition task is a callable object that takes no arguments and returns a tf::SmallVector<int>. The returned vector contains branch indices for multiple successor branches, enabling complex control flow patterns where a single task can activate multiple branches simultaneously.
- Requirements
- Must be invocable with no arguments
- Must return exactly tf::SmallVector<int>
- Examples
auto multi_condition1 = []() {
branches.push_back(0);
branches.push_back(2);
return branches;
};
int branch_mask = 5;
auto select_branches = [branch_mask]() {
for(int i = 0; i < 3; ++i) {
if(branch_mask & (1 << i)) {
result.push_back(i);
}
}
return result;
};
static_assert(MultiConditionTaskLike<decltype(select_branches)>);
struct MultiConditionTask {
tf::SmallVector<int> operator()() const {
return {0, 1};
}
};
static_assert(MultiConditionTaskLike<MultiConditionTask>);
auto [init, mcond, branch_0, branch_1, branch_2] = taskflow.
emplace(
[](){ std::cout << "init\n"; },
select_branches,
[](){ std::cout << "branch 0\n"; },
[](){ std::cout << "branch 1\n"; },
[](){ std::cout << "branch 2\n"; }
);
mcond.
precede(branch_0, branch_1, branch_2);
Task emplace(C &&callable)
creates a static task
Definition flow_builder.hpp:1562
Task & precede(Ts &&... tasks)
adds precedence links from this to other tasks
Definition task.hpp:1258
class to create a taskflow object
Definition taskflow.hpp:64
- Invalid Examples
auto not_multi1 = [](int x) {
};
auto not_multi2 = []() { return std::vector<int>{0, 1}; };
auto not_multi3 = []() { return 0; };
auto not_multi4 = []() { std::cout << "task\n"; };