diff options
author | David Tolnay <dtolnay@gmail.com> | 2021-01-02 11:52:39 -0800 |
---|---|---|
committer | David Tolnay <dtolnay@gmail.com> | 2021-01-02 11:55:25 -0800 |
commit | 672c464c72b7fef40c9f83f1f0532b13e35347c9 (patch) | |
tree | 782cf54117f49ff72284083534486497bc6d5745 /include | |
parent | 357d9ed5e418d97600edeb84d75fec9230a96cca (diff) | |
download | cxx-672c464c72b7fef40c9f83f1f0532b13e35347c9.tar.gz |
Remove implicit Box copy operations to match unique_ptr
Diffstat (limited to 'include')
-rw-r--r-- | include/cxx.h | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/include/cxx.h b/include/cxx.h index d50045aa..d32e17f1 100644 --- a/include/cxx.h +++ b/include/cxx.h @@ -228,14 +228,12 @@ public: using pointer = typename std::add_pointer<T>::type; Box() = delete; - Box(const Box &); Box(Box &&) noexcept; ~Box() noexcept; explicit Box(const T &); explicit Box(T &&); - Box &operator=(const Box &); Box &operator=(Box &&) noexcept; const T *operator->() const noexcept; @@ -688,9 +686,6 @@ public: }; template <typename T> -Box<T>::Box(const Box &other) : Box(*other) {} - -template <typename T> Box<T>::Box(Box &&other) noexcept : ptr(other.ptr) { other.ptr = nullptr; } @@ -719,19 +714,6 @@ Box<T>::~Box() noexcept { } template <typename T> -Box<T> &Box<T>::operator=(const Box &other) { - if (this->ptr) { - **this = *other; - } else { - allocation alloc; - ::new (alloc.ptr) T(*other); - this->ptr = alloc.ptr; - alloc.ptr = nullptr; - } - return *this; -} - -template <typename T> Box<T> &Box<T>::operator=(Box &&other) noexcept { if (this->ptr) { this->drop(); |