From 98aefb59d871d28e46f6ddbda767e79b60a80ac4 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Tue, 6 Mar 2018 21:50:25 +0100 Subject: [PATCH] First attempt on making all promises non-copyable * Fix CONTINUABLE_WITH_UNHANDLED_ERRORS when using the promise as real callback. --- include/continuable/detail/base.hpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/include/continuable/detail/base.hpp b/include/continuable/detail/base.hpp index 71f1cd6..d26d860 100644 --- a/include/continuable/detail/base.hpp +++ b/include/continuable/detail/base.hpp @@ -392,9 +392,8 @@ struct callback_base, HandleResults, proto::error_handler_base< HandleErrors, callback_base, HandleResults, - HandleErrors, Callback, Executor, NextCallback>> { - - using CallbackT = Callback; + HandleErrors, Callback, Executor, NextCallback>>, + util::non_copyable { Callback callback_; Executor executor_; @@ -445,16 +444,12 @@ auto make_callback(Callback&& callback, Executor&& executor, /// Once this was a workaround for GCC bug: /// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64095 -struct final_callback { +struct final_callback : util::non_copyable { template void operator()(Args... /*args*/) && { } - template - void set_value(Args... /*args*/) { - } - - void set_exception(types::error_type error) { + void operator()(types::dispatch_error_tag, types::error_type error) && { (void)error; #ifndef CONTINUABLE_WITH_UNHANDLED_ERRORS // There were unhandled errors inside the asynchronous call chain! @@ -463,6 +458,15 @@ struct final_callback { util::trap(); #endif // CONTINUABLE_WITH_UNHANDLED_ERRORS } + + template + void set_value(Args... args) { + std::move (*this)(std::forward(args)...); + } + + void set_exception(types::error_type error) { + std::move (*this)(types::dispatch_error_tag{}, std::move(error)); + } }; } // namespace callbacks