From da4ff40f76171947c7012d6c301a9c359d23a24e Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 28 Dec 2021 01:29:54 +0300 Subject: [PATCH] Fix SFINAE usage in PromiseFuture.h. --- tdactor/td/actor/PromiseFuture.h | 52 ++++++++++++-------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/tdactor/td/actor/PromiseFuture.h b/tdactor/td/actor/PromiseFuture.h index 59c034150..ca4245624 100644 --- a/tdactor/td/actor/PromiseFuture.h +++ b/tdactor/td/actor/PromiseFuture.h @@ -184,38 +184,20 @@ class SafePromise; template class Promise; -constexpr inline std::false_type is_promise_interface(...) { - return {}; -} +template +struct is_promise_interface : std::false_type {}; + +template +struct is_promise_interface> : std::true_type {}; + +template +struct is_promise_interface> : std::true_type {}; template -constexpr std::true_type is_promise_interface(const PromiseInterface &promise) { - return {}; -} +struct is_promise_interface_ptr : std::false_type {}; -template -constexpr std::true_type is_promise_interface(const Promise &promise) { - return {}; -} - -template -constexpr bool is_promise_interface() { - return decltype(is_promise_interface(std::declval()))::value; -} - -constexpr inline std::false_type is_promise_interface_ptr(...) { - return {}; -} - -template -constexpr std::true_type is_promise_interface_ptr(const unique_ptr &promise) { - return {}; -} - -template -constexpr bool is_promise_interface_ptr() { - return decltype(is_promise_interface_ptr(std::declval()))::value; -} +template +struct is_promise_interface_ptr> : std::true_type {}; template ::value, bool> has_t = false> auto lambda_promise(F &&f) { @@ -227,22 +209,26 @@ auto lambda_promise(F &&f) { return detail::LambdaPromise>(std::forward(f)); } -template (), bool> from_promise_interface = true> +template >::value, bool> from_promise_interface = true> auto &&promise_interface(F &&f) { return std::forward(f); } -template (), bool> from_promise_interface = false> +template >::value, bool> from_promise_interface = false> auto promise_interface(F &&f) { return lambda_promise(std::forward(f)); } -template (), bool> from_promise_interface = true> +template >::value, bool> from_promise_interface = true> auto promise_interface_ptr(F &&f) { return std::forward(f); } -template (), bool> from_promise_interface = false> +template >::value, bool> from_promise_interface = false> auto promise_interface_ptr(F &&f) { return td::make_unique(std::forward(f)))>>( promise_interface(std::forward(f)));