Skip to content

Commit 5e736fe

Browse files
author
Chun-Xun Lin
committed
Fix the VS compilation error in FlowBuilder:emplace. Fix the float to int conversion in reduce.cpp
1 parent ae238f5 commit 5e736fe

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

example/reduce.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void transform_reduce() {
7575
tf::Taskflow tf;
7676
auto tmin = std::numeric_limits<int>::max();
7777
tf.transform_reduce(data.begin(), data.end(), tmin,
78-
[] (float l, float r) { return std::min(l, r); },
78+
[] (int l, int r) { return std::min(l, r); },
7979
[] (const Data& d) { return d.transform(); }
8080
);
8181
tf.wait_for_all();

taskflow/taskflow.hpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -978,18 +978,19 @@ auto BasicFlowBuilder<NodeType>::emplace(C&& c) {
978978
std::promise<R> p;
979979
auto fu = p.get_future();
980980

981-
auto& node = _nodes.emplace_front(
982-
[p=MoC(std::move(p)), c=std::forward<C>(c)] () mutable {
983-
if constexpr(std::is_same_v<void, R>) {
984-
c();
985-
p.get().set_value();
986-
}
987-
else {
988-
p.get().set_value(c());
989-
}
990-
}
991-
);
992-
return std::make_pair(TaskType(node), std::move(fu));
981+
if constexpr(std::is_same_v<void, R>) {
982+
auto& node = _nodes.emplace_front([p = MoC(std::move(p)), c = std::forward<C>(c)]() mutable {
983+
c();
984+
p.get().set_value();
985+
});
986+
return std::make_pair(TaskType(node), std::move(fu));
987+
}
988+
else {
989+
auto& node = _nodes.emplace_front([p = MoC(std::move(p)), c = std::forward<C>(c)]() mutable {
990+
p.get().set_value(c());
991+
});
992+
return std::make_pair(TaskType(node), std::move(fu));
993+
}
993994
}
994995
else {
995996
static_assert(dependent_false_v<C>, "invalid task work type");

0 commit comments

Comments
 (0)