diff --git a/include/continuable/continuable-promise-base.hpp b/include/continuable/continuable-promise-base.hpp index 5828be2..8702f81 100644 --- a/include/continuable/continuable-promise-base.hpp +++ b/include/continuable/continuable-promise-base.hpp @@ -37,12 +37,14 @@ #include #include #include +#include namespace cti { template class promise_base; template -class promise_base> { +class promise_base> + : detail::util::non_copyable { /// \cond false // The callback type Data data_; @@ -59,27 +61,19 @@ public: promise_base(OData&& data) : data_(std::forward(data)) { } - /// \cond false - promise_base(promise_base&&) = default; - promise_base(promise_base const&) = default; - - promise_base& operator=(promise_base&&) = default; - promise_base& operator=(promise_base const&) = default; - /// \endcond + /// Resolves the continuation with the given values + void operator()(Args... args) { + data_(std::move(args)...); + } /// Resolves the continuation with the given values void set_value(Args... args) { data_(std::move(args)...); } - /// Resolves the continuation with the given values - void operator()(Args... args) { - data_(std::move(args)...); - } - - /// Resolves the continuation with the given error variable. - void set_error(detail::types::error_type error) { - data_(detail::types::dispatch_error_tag{}, std::move(error)); + /// Resolves the continuation with the given exception + void set_exception(detail::types::error_type exception) { + data_(detail::types::dispatch_error_tag{}, std::move(exception)); } }; } // namespace cti diff --git a/include/continuable/detail/base.hpp b/include/continuable/detail/base.hpp index e3148b1..4b7dd27 100644 --- a/include/continuable/detail/base.hpp +++ b/include/continuable/detail/base.hpp @@ -309,7 +309,7 @@ struct result_callback, Callback, Executor, } /// Resolves the continuation with the given error variable. - void set_error(types::error_type error) { + void set_exception(types::error_type error) { std::move(next_callback_)(types::dispatch_error_tag{}, std::move(error)); } }; @@ -348,7 +348,7 @@ struct error_callback, Callback, Executor, } /// Resolves the continuation with the given error variable. - void set_error(types::error_type error) { + void set_exception(types::error_type error) { std::move(next_callback_)(types::dispatch_error_tag{}, std::move(error)); } }; @@ -364,7 +364,7 @@ struct empty_callback { void set_value(Args... /*error*/) { } - void set_error(types::error_type /*error*/) { + void set_exception(types::error_type /*error*/) { } }; } // namespace callbacks diff --git a/test/playground/test-playground.cpp b/test/playground/test-playground.cpp index b6c3dc4..e470410 100644 --- a/test/playground/test-playground.cpp +++ b/test/playground/test-playground.cpp @@ -26,7 +26,7 @@ cti::continuable http_request(std::string url) { return [](cti::promise promise) { - promise.set_error(nullptr); + promise.set_exception(nullptr); promise.set_value(""); promise(""); }; @@ -34,7 +34,7 @@ cti::continuable http_request(std::string url) { auto http_request2(std::string url) { return cti::make_continuable([](auto&& promise) { - promise.set_error(nullptr); + promise.set_exception(nullptr); promise.set_value(""); promise(""); });