determines if a callable is a condition task
A condition task is a callable object that takes no arguments and returns a value convertible to int. The returned int value controls which successor branch is taken in conditional execution (if-else branching).
- Requirements
- Must be invocable with no arguments
- Must return a value convertible to int
- Examples
auto condition_task1 = []() { return 0; };
int counter = 0;
auto condition_task2 = [counter]() {
return (counter > 5) ? 1 : 0;
};
static_assert(ConditionTaskLike<decltype(condition_task2)>);
auto evaluate_path = []() {
return rand() % 3;
};
static_assert(ConditionTaskLike<decltype(evaluate_path)>);
struct ConditionTask {
int operator()() const { return 42; }
};
static_assert(ConditionTaskLike<ConditionTask>);
auto bool_condition = []() { return true; };
static_assert(ConditionTaskLike<decltype(bool_condition)>);
auto [init, cond, branch_a, branch_b] = taskflow.
emplace(
[](){ std::cout << "init\n"; },
condition_task1,
[](){ std::cout << "branch a\n"; },
[](){ std::cout << "branch b\n"; }
);
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_condition1 = [](int x) { return x; };
auto not_condition2 = []() { return std::string("hello"); };
auto not_condition3 = []() { std::cout << "task\n"; };