Код: Выделить всё
#include
#include
#include
10 template
11 class Task {
12 std::function m_fn;
13
14 public:
15 typedef R return_type;
16
17 template
18 auto Then(F&& f) {
19 using ReturnType = typename std::result_of::type;
20 auto func = std::move(m_fn);
21 return Task([func, &f](Args&&... args)
22 {
23 std::future lastf = std::async(func, std::forward(args)...);
24 return std::async(f, lastf.get()).get();
25 }); }
Код: Выделить всё
Task.hpp: In instantiation of ‘auto Cosmos::Task::Then(F&&) [with F = std::function; R = std::pair; Args = {}]’: TaskCpp.cpp:93:7: required from here Task.hpp:19:10: error: no type named ‘type’ in ‘class std::result_of’ 19 | using ReturnType = typename std::result_of::type; | ^~~~~~~~~~ Task.hpp:21:11: error: no type named ‘type’ in ‘class std::result_of’ 21 | return Task([func, &f](Args&&... args) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 | { | ~ 23 | std::future lastf = std::async(func, std::forward(args)...); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 | return std::async(f, lastf.get()).get(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 | }); | ~~ Task.hpp:24:22: error: no matching function for call to ‘async(std::function&, std::pair)’ 24 | return std::async(f, lastf.get()).get();
Подробнее здесь: https://stackoverflow.com/questions/787 ... intstdpair