mirror of
https://github.com/Naios/continuable.git
synced 2025-12-08 01:36:46 +08:00
Fix the examples after the r-value qualification in 84ca172caa3
This commit is contained in:
parent
84ca172caa
commit
616b68c008
@ -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() {
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user