| 729 | { |
| 730 | template <typename F, typename = std::enable_if_t<!std::is_same_v<std::decay_t<F>, task_and_future<R>>>> |
| 731 | explicit task_and_future(F&& func) |
| 732 | { |
| 733 | std::promise<R> promise; |
| 734 | future = promise.get_future(); |
| 735 | task = [task = std::forward<F>(func), promise = std::move(promise)]() mutable |
| 736 | { |
| 737 | #ifdef __cpp_exceptions |
| 738 | try |
| 739 | { |
| 740 | #endif |
| 741 | if constexpr (std::is_void_v<R>) |
| 742 | { |
| 743 | task(); |
| 744 | promise.set_value(); |
| 745 | } |
| 746 | else |
| 747 | { |
| 748 | promise.set_value(task()); |
| 749 | } |
| 750 | #ifdef __cpp_exceptions |
| 751 | } |
| 752 | catch (...) |
| 753 | { |
| 754 | try |
| 755 | { |
| 756 | promise.set_exception(std::current_exception()); |
| 757 | } |
| 758 | catch (...) |
| 759 | { |
| 760 | } |
| 761 | } |
| 762 | #endif |
| 763 | }; |
| 764 | } |
| 765 | |
| 766 | std::future<R> future; |
| 767 | task_t task; |
nothing calls this directly
no outgoing calls
no test coverage detected