Remove implicit Box copy operations to match unique_ptr
diff --git a/include/cxx.h b/include/cxx.h
index d50045a..d32e17f 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -228,14 +228,12 @@
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 @@
};
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 @@
}
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();
diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc
index 96c5cab..39d97bd 100644
--- a/tests/ffi/tests.cc
+++ b/tests/ffi/tests.cc
@@ -64,9 +64,8 @@
Shared shared{0};
rust::Box<Shared> box{shared}; // explicit constructor from const T&
rust::Box<Shared> other{std::move(shared)}; // explicit constructor from T&&
- box = other; // copy assignment
box = std::move(other); // move assignment
- rust::Box<Shared> box2(box); // copy constructor
+ rust::Box<Shared> box2(*box); // copy from another Box
rust::Box<Shared> other2(std::move(other)); // move constructor
rust::Box<Shared>::in_place(shared.z); // placement static factory
rust::Box<Shared>::in_place<size_t>(0);