https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97207
--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #10)
> If you don't want to support assignment you can still support swapping:
>
> --- a/gcc/vec.h
> +++ b/gcc/vec.h
> @@ -1546,9 +1546,21 @@ public:
> this->m_vec = r.m_vec;
> r.m_vec = NULL;
> }
> +
> void operator= (auto_vec&&) = delete;
> +
> + void swap(auto_vec&& r)
> + {
> + std::swap(this->m_vec = r.m_vec);
Oops, copy&paste error, that should be:
std::swap(this->m_vec, r.m_vec);
To add move assignment and swap:
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -1546,9 +1546,26 @@ public:
this->m_vec = r.m_vec;
r.m_vec = NULL;
}
- void operator= (auto_vec&&) = delete;
+
+ auto_vec& operator= (auto_vec&& r)
+ {
+ this->release();
+ this->swap(r);
+ return *this;
+ }
+
+ void swap(auto_vec&& r)
+ {
+ std::swap(this->m_vec, r.m_vec);
+ }
};
+template<typename T>
+void swap(auto_vec<T>& l, auto_vec<T>& r)
+{
+ l.swap(r);
+}
+
/* Allocate heap memory for pointer V and create the internal vector
with space for NELEMS elements. If NELEMS is 0, the internal