c++11 async continuations or attempt at .then() semantics

前端 未结 2 1677
温柔的废话
温柔的废话 2020-12-13 05:57

The code below is based on Herb Sutter\'s ideas of an implementation of a .then() type continuation.

  template
auto then(F         


        
2条回答
  •  既然无缘
    2020-12-13 06:01

    Here is the solution, tested with g++ 4.8 and clang++ 3.2:

    template
    auto then(F&& f, W w) -> std::future
    {
      cout<<"In thread id = "< result=std::async([]{ return 12;});
      auto f = then(std::move(result), [](int r) {
        cout<<"[after] thread id = "<
                                                            
提交回复
热议问题