Bundle& Bundle::operator = (const Bundle& b) {
if (this != &b) {
+ if (impl_->handle_ && (impl_->own_ || impl_->copy_))
+ bundle_free(impl_->handle_);
+
impl_->handle_ = bundle_dup(b.impl_->handle_);
if (impl_->handle_ == nullptr)
throw std::bad_alloc();
+
+ impl_->own_ = true;
+ impl_->copy_ = true;
}
return *this;
}
Bundle& Bundle::operator = (Bundle&& b) noexcept {
if (this != &b) {
+ if (impl_->handle_ && (impl_->own_ || impl_->copy_))
+ bundle_free(impl_->handle_);
+
impl_->handle_ = b.impl_->handle_;
b.impl_->handle_ = nullptr;
+ impl_->own_ = b.impl_->own_;
+ impl_->copy_ = b.impl_->copy_;
}
return *this;
}