diff --git a/tdutils/td/utils/port/CxCli.h b/tdutils/td/utils/port/CxCli.h index bac7a8b0f..778f5cabc 100644 --- a/tdutils/td/utils/port/CxCli.h +++ b/tdutils/td/utils/port/CxCli.h @@ -49,9 +49,15 @@ public: value = it->second; return true; } - void TryRemove(Key key, Value &value) { + bool TryRemove(Key key, Value &value) { std::lock_guard guard(mutex_); - impl_.erase(key); + auto it = impl_.find(key); + if (it == impl_.end()) { + return false; + } + value = std::move(it->second); + impl_.erase(it); + return true; } Value &operator [] (Key key) { std::lock_guard guard(mutex_);