1

Here's an example:

#include <vector>
#include <future>
using namespace std;

int f(){ return 3; }

int main(){
    vector<future<int>> works;
    works.push_back(async(f));

    vector<int> works2{f()};

    vector<future<int>> fails{async(f)};
}

Unless I comment out the last line I get:

use of deleted function ‘std::future<_Res>::future(const std::future<_Res>&) [with _Res = int]’
     { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }

with gcc 7. If I understand it it says that it can't construct a future from a reference to a future. But I can't construct myself an understanding of this that's consistent with it working with the push_back.

acupoftea
  • 179
  • 1
  • 10

0 Answers0