Commit f6ed8ccd authored by guoping.luo's avatar guoping.luo

Make mutable lambda functions can be accepted by future then

parent cf0af7de
......@@ -33,7 +33,8 @@ public:
disposable then(OnSuccess on_success, OnError on_error) {
static_assert(std::is_invocable_v<OnSuccess, const T&>);
static_assert(std::is_invocable_v<OnError, const error&>);
auto cb = [cp = cell_, f = std::move(on_success), g = std::move(on_error)] {
auto cb = [cp = cell_, f = std::move(on_success),
g = std::move(on_error)]() mutable {
// Note: no need to lock the mutex. Once the cell has a value and actions
// are allowed to run, the value is immutable.
switch (cp->value.index()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment