!31353 fix code check

Merge pull request !31353 from lianliguang/master
This commit is contained in:
i-robot 2022-03-17 02:16:52 +00:00 committed by Gitee
commit a25c5b46aa
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 7 additions and 1 deletions

View File

@ -31,10 +31,16 @@ class UserData {
UserData(const UserData &other) : data_(other.data_ ? std::make_unique<DataMap>(*other.data_) : nullptr) {}
UserData(UserData &&other) : data_(std::move(other.data_)) {}
UserData &operator=(const UserData &other) {
if (this == &other) {
return *this;
}
data_ = (other.data_ ? std::make_unique<DataMap>(*other.data_) : nullptr);
return *this;
}
UserData &operator=(UserData &&other) {
if (this == &other) {
return *this;
}
data_ = std::move(other.data_);
return *this;
}
@ -44,7 +50,7 @@ class UserData {
void set(const std::string &key, const std::shared_ptr<T> &value) {
InitData();
if (value == nullptr) {
data_->erase(key);
(void)data_->erase(key);
} else {
data_->insert_or_assign(key, value);
}