无法使std :: async()工作

时间:2015-06-28 14:04:54

标签: c++ c++11 concurrency

我刚刚开始研究c ++ 11 std中的并发性但是我无法让这个程序编译

 #include<future>
 #include<iostream>


 int func1(const int &i)
 {
   return i*i;  

 }


 int func2(const int &i)
 {


      return 2*i;
 }

 int main()
 {


    auto result1(std::async(func1,2));//error in this line says invalid use of incomplete type 'class std::future<int>'
    int result2 = func2(4);
    int result = result1.get() + result2;
    std::cout<<"\t result"<<result;
    return 0;
 }

有人可以解释我也尝试使用std :: future而不是auto的错误,但它不起作用。

0 个答案:

没有答案
相关问题