O'Reilly logo

C++17 STL Cookbook by Jacek Galowicz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required