Add checks that delete is not called for incomplete type.
GitOrigin-RevId: 19755ebbee56eb874e84fd8544899fd70a78df7f
This commit is contained in:
parent
cb71adbfd5
commit
16bd7bd98e
@ -124,6 +124,7 @@ class unique_ptr {
|
||||
return *this;
|
||||
}
|
||||
void reset(T *new_ptr = nullptr) noexcept {
|
||||
static_assert(sizeof(T) > 0, "Can't destroy unique_ptr with incomplete type");
|
||||
delete ptr_;
|
||||
ptr_ = new_ptr;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ class unique_ptr final {
|
||||
return *this;
|
||||
}
|
||||
void reset(T *new_ptr = nullptr) noexcept {
|
||||
static_assert(sizeof(T) > 0, "Can't destroy unique_ptr with incomplete type");
|
||||
delete ptr_;
|
||||
ptr_ = new_ptr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user