From 86573be3ad3e0805081b708f0b5882091f94b06e Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 26 Nov 2020 23:17:45 +0300 Subject: [PATCH] Minor fixes. --- tdactor/td/actor/PromiseFuture.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tdactor/td/actor/PromiseFuture.h b/tdactor/td/actor/PromiseFuture.h index 08b8ca485..e6ffbc8f5 100644 --- a/tdactor/td/actor/PromiseFuture.h +++ b/tdactor/td/actor/PromiseFuture.h @@ -20,6 +20,7 @@ #include namespace td { + template class PromiseInterface { public: @@ -101,6 +102,7 @@ struct Ignore { error.ignore(); } }; + template class LambdaPromise : public PromiseInterface { enum class OnFail { None, Ok, Fail }; @@ -129,7 +131,8 @@ class LambdaPromise : public PromiseInterface { LambdaPromise(FromOkT &&ok, FromFailT &&fail, bool use_ok_as_fail) : ok_(std::forward(ok)) , fail_(std::forward(fail)) - , on_fail_(use_ok_as_fail ? OnFail::Ok : OnFail::Fail), has_lambda_(true) { + , on_fail_(use_ok_as_fail ? OnFail::Ok : OnFail::Fail) + , has_lambda_(true) { } template LambdaPromise(FromOkT &&ok) : LambdaPromise(std::move(ok), Ignore(), true) { @@ -167,12 +170,12 @@ class LambdaPromise : public PromiseInterface { std::enable_if_t>::value, void> do_ok(F &&f, ValueT &&result) { f(Result(std::move(result))); } - template + template std::enable_if_t>::value, void> do_ok(F &&f, ValueT &&result) { f(std::move(result)); } }; -} +} // namespace detail template class SafePromise; @@ -211,34 +214,34 @@ constexpr bool is_promise_interface_ptr() { } template ::value, bool> has_t = false> auto lambda_promise(F &&f) { - return detail::LambdaPromise>>, std::decay_t>(std::forward(f)); + return detail::LambdaPromise>>, std::decay_t>( + std::forward(f)); } template ::value, bool> has_t = true> auto lambda_promise(F &&f) { return detail::LambdaPromise>(std::forward(f)); } -template (), bool> from_promise_inerface = true> +template (), bool> from_promise_interface = true> auto &&promise_interface(F &&f) { return std::forward(f); } -template (), bool> from_promise_inerface = false> +template (), bool> from_promise_interface = false> auto promise_interface(F &&f) { return lambda_promise(std::forward(f)); } -template (), bool> from_promise_inerface = true> +template (), bool> from_promise_interface = true> auto promise_interface_ptr(F &&f) { return std::forward(f); } -template (), bool> from_promise_inerface = false> +template (), bool> from_promise_interface = false> auto promise_interface_ptr(F &&f) { return td::make_unique(std::forward(f)))>>( promise_interface(std::forward(f))); } - template class Promise { public: @@ -420,7 +423,6 @@ class CancellablePromise : public PromiseT { CancellationToken cancellation_token_; }; - template class JoinPromise : public PromiseInterface { public: @@ -694,8 +696,7 @@ class PromiseCreator { template >> static Promise lambda(OkT &&ok) { - return Promise( - td::make_unique>>(std::forward(ok))); + return Promise(td::make_unique>>(std::forward(ok))); } template > @@ -706,9 +707,8 @@ class PromiseCreator { template >> static auto cancellable_lambda(CancellationToken cancellation_token, OkT &&ok) { - return Promise( - td::make_unique>>>( - std::move(cancellation_token), std::forward(ok))); + return Promise(td::make_unique>>>( + std::move(cancellation_token), std::forward(ok))); } static Promise<> event(EventFull &&ok) {