Transforming continuables
Explains the conversion into other types such as std::future.
Transforms in general
Sometimes it's required to change a continuable_
A transformation accepts a continuable_
To create a transformation use the make_
auto transform = cti::make_transform([] (auto&& continuable) { // Change the continuable return std::forward<decltype(continuable)>(continuable); });
The library provides several transforms already as part of the cti::
Conversion into std::future
The library is capable of converting (futurizing) every continuable into a fitting std::future through the transforms::
std::future<std::string> future = http_request("github.com") .then([](std::string response) { // Do sth... return http_request("travis-ci.org") || http_request("atom.io"); }) .apply(cti::transforms::futurize()); // ^^^^^^^^
Multiple arguments which can't be handled by std::future itself are converted into std::tuple, see transforms::
std::future<std::tuple<std::string, std::string>> future = (http_request("travis-ci.org") && http_request("atom.io")) .apply(cti::transforms::futurize());