Daily bit(e) of C++ | std::async, std::launch
Daily bit(e) of C++ #446, Launching or deferring callables using std::async and std::launch.
The std::async and its accompanying launch policies std::launch::deferred and std::launch::async is a tool for running a callable either lazily or asynchronously.
The std::async returns a std::future that can be used to wait for the result (or, in the case of the deferred launch policy, evaluate the callable).
When you have iterator and want a vector, you do not have to copy, just use the ctor or vector::assign, keep it simple :-)
return std::vector(std::istreambuf_iterator<char>{file}, std::streambuf_iterator<char>{});