Awaiting for the ranges: C++17

There are two features planned for C++17 that are poised to reinvent the language like the lambdas and auto did for C++11. Those are the ranges (N4128) and the await (N4134).

Ranges are objects that represent a sequence of elements in a similar, but improved manner compared to the iterator pairs. Algorithms on ranges are more general and easy to compose, unlike their iterator-pair counterparts. They bring one of the most popular and most often touted features of functional programming languages to C++.


The 'Await 2.o' proposal brings another feature to C++ - building continuation (future.then) execution into the syntax of the language. Instead of registering a callback function for a specific event, the compiler does that for you by (in layman terms) creating the callback function automatically from the code that comes after the await expression.


These two features seem to have nothing in common, but we will see the power of connecting them if we just dig a little bit deeper. We just need to broaden the view of what we consider to be a range to the things that look like collections, but collections whose elements might not be known until some point in time. With that, and the ability to await for the next item in the range, we get the power of collection processing applied to event handling, data streams, and much more.


With these, C++ enters the young 'reactive programming' crowd as a first-class citizen.

Speaker: Ivan Cukic

Slides: Awaiting for the ranges: C++17

Go back