Disallow assignment to rvalue
diff --git a/include/cxx.h b/include/cxx.h
index 0744f8c..654b176 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -44,8 +44,8 @@
String(const char *);
String(const char *, std::size_t);
- String &operator=(const String &) noexcept;
- String &operator=(String &&) noexcept;
+ String &operator=(const String &) & noexcept;
+ String &operator=(String &&) & noexcept;
explicit operator std::string() const;
@@ -97,7 +97,7 @@
Str(const char *);
Str(const char *, std::size_t);
- Str &operator=(const Str &) noexcept = default;
+ Str &operator=(const Str &) & noexcept = default;
explicit operator std::string() const;
@@ -144,8 +144,8 @@
struct copy_assignable_if<false> {
copy_assignable_if() noexcept = default;
copy_assignable_if(const copy_assignable_if &) noexcept = default;
- copy_assignable_if &operator=(const copy_assignable_if &) noexcept = delete;
- copy_assignable_if &operator=(copy_assignable_if &&) noexcept = default;
+ copy_assignable_if &operator=(const copy_assignable_if &) & noexcept = delete;
+ copy_assignable_if &operator=(copy_assignable_if &&) & noexcept = default;
};
} // namespace detail
@@ -159,8 +159,8 @@
Slice() noexcept;
Slice(T *, std::size_t count) noexcept;
- Slice &operator=(const Slice<T> &) noexcept = default;
- Slice &operator=(Slice<T> &&) noexcept = default;
+ Slice &operator=(const Slice<T> &) & noexcept = default;
+ Slice &operator=(Slice<T> &&) & noexcept = default;
T *data() const noexcept;
std::size_t size() const noexcept;
@@ -248,7 +248,7 @@
explicit Box(const T &);
explicit Box(T &&);
- Box &operator=(Box &&) noexcept;
+ Box &operator=(Box &&) & noexcept;
const T *operator->() const noexcept;
const T &operator*() const noexcept;
@@ -293,8 +293,8 @@
Vec(Vec &&) noexcept;
~Vec() noexcept;
- Vec &operator=(Vec &&) noexcept;
- Vec &operator=(const Vec &);
+ Vec &operator=(Vec &&) & noexcept;
+ Vec &operator=(const Vec &) &;
std::size_t size() const noexcept;
bool empty() const noexcept;
@@ -371,8 +371,8 @@
Error(Error &&) noexcept;
~Error() noexcept override;
- Error &operator=(const Error &);
- Error &operator=(Error &&) noexcept;
+ Error &operator=(const Error &) &;
+ Error &operator=(Error &&) & noexcept;
const char *what() const noexcept override;
@@ -735,7 +735,7 @@
}
template <typename T>
-Box<T> &Box<T>::operator=(Box &&other) noexcept {
+Box<T> &Box<T>::operator=(Box &&other) & noexcept {
if (this->ptr) {
this->drop();
}
@@ -823,7 +823,7 @@
}
template <typename T>
-Vec<T> &Vec<T>::operator=(Vec &&other) noexcept {
+Vec<T> &Vec<T>::operator=(Vec &&other) & noexcept {
this->drop();
this->repr = other.repr;
new (&other) Vec();
@@ -831,7 +831,7 @@
}
template <typename T>
-Vec<T> &Vec<T>::operator=(const Vec &other) {
+Vec<T> &Vec<T>::operator=(const Vec &other) & {
if (this != &other) {
this->drop();
new (this) Vec(other);