#include <algorithm>
#include <cstring>
+#include <memory>
#include <utility>
#include "include/bundle.h"
}
Bundle::Bundle(const Bundle& b) {
- map_ = b.map_;
- list_ = b.list_;
+ for (const auto& [key, val] : b.map_) {
+ const KeyInfo& info = *val;
+ auto new_val = std::make_shared<KeyInfo>(info);
+ map_[key] = new_val;
+ list_.push_back(std::move(new_val));
+ }
}
Bundle& Bundle::operator = (const Bundle& b) {
if (this != &b) {
- map_ = b.map_;
- list_ = b.list_;
+ map_.clear();
+ list_.clear();
+ for (const auto& [key, val] : b.map_) {
+ const KeyInfo& info = *val;
+ auto new_val = std::make_shared<KeyInfo>(info);
+ map_[key] = new_val;
+ list_.push_back(std::move(new_val));
+ }
}
return *this;
}
return false;
auto& rhs = iter->second;
- if (!(lhs == rhs))
+ if (!(*lhs == *rhs))
return false;
}