From ba2f63f8b00be2796a75fb67a6d2758b0a9f1a6f Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 22 Feb 2024 00:57:54 +0300 Subject: [PATCH] Remove LambdaPromise debug to avoid compiler errors because of #define lambda(...). --- tdutils/td/utils/Promise.h | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tdutils/td/utils/Promise.h b/tdutils/td/utils/Promise.h index 183797e88..ce4365d2a 100644 --- a/tdutils/td/utils/Promise.h +++ b/tdutils/td/utils/Promise.h @@ -94,7 +94,7 @@ class LambdaPromise : public PromiseInterface { public: void set_value(ValueT &&value) override { - CHECK_IMPL(state_.get() == State::Ready, file_, line_); + CHECK(state_.get() == State::Ready); do_ok(std::move(value)); state_ = State::Complete; } @@ -116,15 +116,12 @@ class LambdaPromise : public PromiseInterface { } template - LambdaPromise(const char *file, int line, FromT &&func) - : func_(std::forward(func)), state_(State::Ready), file_(file), line_(line) { + LambdaPromise(FromT &&func) : func_(std::forward(func)), state_(State::Ready) { } private: FunctionT func_; MovableValue state_{State::Empty}; - const char *file_ = ""; - int line_ = 0; template std::enable_if_t>::value, void> do_error(Status &&status) { @@ -161,12 +158,11 @@ struct is_promise_interface_ptr> : std::true_type {}; template ::value, bool> has_t = false> auto lambda_promise(F &&f) { - return LambdaPromise>>, std::decay_t>(__FILE__, __LINE__, - std::forward(f)); + return LambdaPromise>>, std::decay_t>(std::forward(f)); } template ::value, bool> has_t = true> auto lambda_promise(F &&f) { - return LambdaPromise>(__FILE__, __LINE__, std::forward(f)); + return LambdaPromise>(std::forward(f)); } template { class PromiseCreator { public: template >> - static Promise lambda_impl(const char *file, int line, OkT &&ok) { - return Promise( - td::make_unique>>(file, line, std::forward(ok))); + static Promise lambda(OkT &&ok) { + return Promise(td::make_unique>>(std::forward(ok))); } -#define lambda(...) lambda_impl(__FILE__, __LINE__, __VA_ARGS__) template >> - static auto cancellable_lambda_impl(const char *file, int line, CancellationToken cancellation_token, OkT &&ok) { + static auto cancellable_lambda(CancellationToken cancellation_token, OkT &&ok) { return Promise(td::make_unique>>>( - std::move(cancellation_token), file, line, std::forward(ok))); + std::move(cancellation_token), std::forward(ok))); } -#define cancellable_lambda(...) cancellable_lambda_impl(__FILE__, __LINE__, __VA_ARGS__) template static Promise<> join(ArgsT &&...args) {