How it works...

A plain serial version of this program without any async and future magic would look like the following:

int main(){    string result {        concat(            twice(                concat(                    create("foo "),                    create("bar "))),            concat(                create("this "),                create("that "))) };    cout << result << '\n';}

In this recipe, we wrote the helper functions async_adapter and asynchronize that helped us create new functions from create, concat, and twice. We called those new asynchronous functions pcreate, pconcat, and ptwice.

Let us first ignore the complexity of the implementation of async_adapter and asynchronize, in order to first have a look what this got us.

The serial version looks similar to this code:

string result {concat( ... )};cout << result << '\n';

The parallelized ...

Get C++17 STL Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.