Const-correct tl::unique_ptr.
GitOrigin-RevId: b72a92a7169973c2d95e410cfbfed668a412e7e7
This commit is contained in:
parent
eba99a8957
commit
f08c0180b4
@ -1155,7 +1155,7 @@ tl_object_ptr<td_api::inlineQueryResultVoiceNote> copy(const td_api::inlineQuery
|
||||
|
||||
static tl_object_ptr<td_api::InlineQueryResult> copy_result(const tl_object_ptr<td_api::InlineQueryResult> &obj_ptr) {
|
||||
tl_object_ptr<td_api::InlineQueryResult> result;
|
||||
downcast_call(*obj_ptr, [&result](const auto &obj) { result = copy(obj); });
|
||||
downcast_call(const_cast<td_api::InlineQueryResult &>(*obj_ptr), [&result](const auto &obj) { result = copy(obj); });
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1720,7 +1720,7 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
|
||||
}
|
||||
|
||||
Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contacts_manager,
|
||||
const vector<tl_object_ptr<td_api::textEntity>> &input_entities) {
|
||||
vector<tl_object_ptr<td_api::textEntity>> &&input_entities) {
|
||||
vector<MessageEntity> entities;
|
||||
for (auto &entity : input_entities) {
|
||||
if (entity == nullptr || entity->type_ == nullptr) {
|
||||
|
@ -106,7 +106,7 @@ inline bool operator!=(const FormattedText &lhs, const FormattedText &rhs) {
|
||||
const std::unordered_set<Slice, SliceHash> &get_valid_short_usernames();
|
||||
|
||||
Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contacts_manager,
|
||||
const vector<tl_object_ptr<td_api::textEntity>> &input_entities);
|
||||
vector<tl_object_ptr<td_api::textEntity>> &&input_entities);
|
||||
|
||||
vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<MessageEntity> &entities);
|
||||
|
||||
|
@ -21140,7 +21140,7 @@ void MessagesManager::send_dialog_action(DialogId dialog_id, const tl_object_ptr
|
||||
send_action = make_tl_object<telegram_api::sendMessageRecordVideoAction>();
|
||||
break;
|
||||
case td_api::chatActionUploadingVideo::ID: {
|
||||
auto progress = static_cast<td_api::chatActionUploadingVideo &>(*action).progress_;
|
||||
auto progress = static_cast<const td_api::chatActionUploadingVideo &>(*action).progress_;
|
||||
send_action = make_tl_object<telegram_api::sendMessageUploadVideoAction>(progress);
|
||||
break;
|
||||
}
|
||||
@ -21148,17 +21148,17 @@ void MessagesManager::send_dialog_action(DialogId dialog_id, const tl_object_ptr
|
||||
send_action = make_tl_object<telegram_api::sendMessageRecordAudioAction>();
|
||||
break;
|
||||
case td_api::chatActionUploadingVoiceNote::ID: {
|
||||
auto progress = static_cast<td_api::chatActionUploadingVoiceNote &>(*action).progress_;
|
||||
auto progress = static_cast<const td_api::chatActionUploadingVoiceNote &>(*action).progress_;
|
||||
send_action = make_tl_object<telegram_api::sendMessageUploadAudioAction>(progress);
|
||||
break;
|
||||
}
|
||||
case td_api::chatActionUploadingPhoto::ID: {
|
||||
auto progress = static_cast<td_api::chatActionUploadingPhoto &>(*action).progress_;
|
||||
auto progress = static_cast<const td_api::chatActionUploadingPhoto &>(*action).progress_;
|
||||
send_action = make_tl_object<telegram_api::sendMessageUploadPhotoAction>(progress);
|
||||
break;
|
||||
}
|
||||
case td_api::chatActionUploadingDocument::ID: {
|
||||
auto progress = static_cast<td_api::chatActionUploadingDocument &>(*action).progress_;
|
||||
auto progress = static_cast<const td_api::chatActionUploadingDocument &>(*action).progress_;
|
||||
send_action = make_tl_object<telegram_api::sendMessageUploadDocumentAction>(progress);
|
||||
break;
|
||||
}
|
||||
@ -21175,7 +21175,7 @@ void MessagesManager::send_dialog_action(DialogId dialog_id, const tl_object_ptr
|
||||
send_action = make_tl_object<telegram_api::sendMessageRecordRoundAction>();
|
||||
break;
|
||||
case td_api::chatActionUploadingVideoNote::ID: {
|
||||
auto progress = static_cast<td_api::chatActionUploadingVideoNote &>(*action).progress_;
|
||||
auto progress = static_cast<const td_api::chatActionUploadingVideoNote &>(*action).progress_;
|
||||
send_action = make_tl_object<telegram_api::sendMessageUploadRoundAction>(progress);
|
||||
break;
|
||||
}
|
||||
|
@ -143,7 +143,8 @@ class GetNearestDcQuery : public Td::ResultHandler {
|
||||
return on_error(id, result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
promise_.set_value(std::move(result_ptr.ok()->country_));
|
||||
auto result = result_ptr.move_as_ok();
|
||||
promise_.set_value(std::move(result->country_));
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) override {
|
||||
@ -319,7 +320,8 @@ class SendCustomRequestQuery : public Td::ResultHandler {
|
||||
return on_error(id, result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
promise_.set_value(std::move(result_ptr.ok()->data_));
|
||||
auto result = result_ptr.move_as_ok();
|
||||
promise_.set_value(std::move(result->data_));
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) override {
|
||||
@ -428,7 +430,8 @@ class GetInviteTextQuery : public Td::ResultHandler {
|
||||
return on_error(id, result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
promise_.set_value(std::move(result_ptr.ok()->message_));
|
||||
auto result = result_ptr.move_as_ok();
|
||||
promise_.set_value(std::move(result->message_));
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) override {
|
||||
|
@ -1688,7 +1688,7 @@ int64 WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formatted
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto r_entities = get_message_entities(td_->contacts_manager_.get(), text->entities_);
|
||||
auto r_entities = get_message_entities(td_->contacts_manager_.get(), std::move(text->entities_));
|
||||
if (r_entities.is_error()) {
|
||||
promise.set_error(r_entities.move_as_error());
|
||||
return 0;
|
||||
|
@ -109,14 +109,15 @@ void DcAuthManager::on_result(NetQueryPtr result) {
|
||||
dc.state = DcInfo::State::Export;
|
||||
break;
|
||||
}
|
||||
auto result_auth_exported = fetch_result<telegram_api::auth_exportAuthorization>(result->ok());
|
||||
if (result_auth_exported.is_error()) {
|
||||
LOG(WARNING) << "Failed to parse result to auth_exportAuthorization: " << result_auth_exported.error();
|
||||
auto r_result_auth_exported = fetch_result<telegram_api::auth_exportAuthorization>(result->ok());
|
||||
if (r_result_auth_exported.is_error()) {
|
||||
LOG(WARNING) << "Failed to parse result to auth_exportAuthorization: " << r_result_auth_exported.error();
|
||||
dc.state = DcInfo::State::Export;
|
||||
break;
|
||||
}
|
||||
dc.export_id = result_auth_exported.ok()->id_;
|
||||
dc.export_bytes = std::move(result_auth_exported.ok()->bytes_);
|
||||
auto result_auth_exported = r_result_auth_exported.move_as_ok();
|
||||
dc.export_id = result_auth_exported->id_;
|
||||
dc.export_bytes = std::move(result_auth_exported->bytes_);
|
||||
break;
|
||||
}
|
||||
case DcInfo::State::BeforeOk: {
|
||||
|
@ -130,13 +130,22 @@ class unique_ptr {
|
||||
ptr_ = nullptr;
|
||||
return res;
|
||||
}
|
||||
T *get() const noexcept {
|
||||
T *get() noexcept {
|
||||
return ptr_;
|
||||
}
|
||||
T *operator->() const noexcept {
|
||||
const T *get() const noexcept {
|
||||
return ptr_;
|
||||
}
|
||||
T &operator*() const noexcept {
|
||||
T *operator->() noexcept {
|
||||
return ptr_;
|
||||
}
|
||||
const T *operator->() const noexcept {
|
||||
return ptr_;
|
||||
}
|
||||
T &operator*() noexcept {
|
||||
return *ptr_;
|
||||
}
|
||||
const T &operator*() const noexcept {
|
||||
return *ptr_;
|
||||
}
|
||||
explicit operator bool() const noexcept {
|
||||
|
Loading…
Reference in New Issue
Block a user