Fix the examples after the r-value qualification in 84ca172caa3

This commit is contained in:
Denis Blank 2017-10-04 17:26:07 +02:00
parent 84ca172caa
commit 616b68c008
2 changed files with 19 additions and 9 deletions

View File

@ -29,14 +29,14 @@ void creating_continuables() {
auto void_continuable = cti::make_continuable<void>([](auto&& callback) {
// ^^^^
// Call the callback later when you have finished your work
callback();
// Call the promise later when you have finished your work
callback.set_value();
});
auto str_continuable =
cti::make_continuable<std::string>([](auto&& callback) {
// ^^^^^^^^^^^
callback("Hello, World!");
callback.set_value("Hello, World!");
});
}
@ -99,8 +99,10 @@ void chaining_continuables() {
}
auto http_request(std::string /*url*/) {
return cti::make_continuable<std::string>(
[](auto&& callback) { callback("<html>...</html>"); });
return cti::make_continuable<std::string>([](auto&& callback) {
// ...
callback.set_value("<html>...</html>");
});
}
void connecting_continuables() {

View File

@ -23,19 +23,27 @@
#include "continuable/continuable.hpp"
cti::continuable<std::string> http_request(std::string /*url*/) {
return cti::make_continuable<std::string>(
[](auto&& callback) { callback("<html>...</html>"); });
return cti::make_continuable<std::string>([](auto&& callback) {
// ...
callback.set_value("<html>...</html>");
});
}
struct ResultSet {};
struct Buffer {};
cti::continuable<ResultSet> mysql_query(std::string /*url*/) {
return cti::make_continuable([](auto&& callback) { callback(ResultSet{}); });
return cti::make_continuable([](auto&& callback) {
// ...
callback.set_value(ResultSet{});
});
}
cti::continuable<Buffer> read_file(std::string /*url*/) {
return cti::make_continuable([](auto&& callback) { callback(Buffer{}); });
return cti::make_continuable([](auto&& callback) {
// ...
callback.set_value(Buffer{});
});
}
struct a {