| 363 | public: |
| 364 | template <typename F> |
| 365 | Task(int num_results, F &&function, double priority = 0) { |
| 366 | using Func = std::remove_reference_t<F>; |
| 367 | priority_ = priority; |
| 368 | results_.Init(num_results); |
| 369 | |
| 370 | if (num_results == ScalarResult) { |
| 371 | // A task with a scalar return value can return anything |
| 372 | wrapped_ = [f = std::forward<F>(function)](Task *t) mutable { |
| 373 | using Func = std::remove_reference_t<F>; |
| 374 | if constexpr (std::is_invocable_v<Func, Task *>) { |
| 375 | t->SetResult(std::forward<F>(f), t); |
| 376 | } else { |
| 377 | static_assert(std::is_invocable_v<Func>, |
| 378 | "The task function must take no arguments or a single Task * pointer."); |
| 379 | t->SetResult(std::forward<F>(f)); |
| 380 | } |
| 381 | }; |
| 382 | } else { |
| 383 | // A task with a non-scalar return value must return a collection or a tuple. |
| 384 | // We can check the return type early (i.e. now) to aid debugging. |
| 385 | CheckFuncResultType<F>(num_results); |
| 386 | wrapped_ = [f = std::forward<F>(function)](Task *t) mutable { |
| 387 | if constexpr (std::is_invocable_v<Func, Task *>) { |
| 388 | t->SetResults(std::forward<F>(f), t); |
| 389 | } else { |
| 390 | static_assert(std::is_invocable_v<Func>, |
| 391 | "The task function must take no arguments or a single Task * pointer."); |
| 392 | t->SetResults(std::forward<F>(f)); |
| 393 | } |
| 394 | }; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | template <typename F> |
| 399 | explicit Task(F &&function, double priority = 0) |
nothing calls this directly
no test coverage detected