@@ -71,6 +71,7 @@ class Vector {
7171 CowData<T> _cowdata;
7272
7373public:
74+ // Must take a copy instead of a reference (see GH-31736).
7475 bool push_back (T p_elem);
7576 _FORCE_INLINE_ bool append (const T &p_elem) { return push_back (p_elem); } // alias
7677 void fill (T p_elem);
@@ -99,12 +100,14 @@ class Vector {
99100 Error resize (Size p_size) { return _cowdata.resize (p_size); }
100101 Error resize_zeroed (Size p_size) { return _cowdata.template resize <true >(p_size); }
101102 _FORCE_INLINE_ const T &operator [](Size p_index) const { return _cowdata.get (p_index); }
103+ // Must take a copy instead of a reference (see GH-31736).
102104 Error insert (Size p_pos, T p_val) { return _cowdata.insert (p_pos, p_val); }
103105 Size find (const T &p_val, Size p_from = 0 ) const { return _cowdata.find (p_val, p_from); }
104106 Size rfind (const T &p_val, Size p_from = -1 ) const { return _cowdata.rfind (p_val, p_from); }
105107 Size count (const T &p_val) const { return _cowdata.count (p_val); }
106108
107- void append_array (const Vector<T> &p_other);
109+ // Must take a copy instead of a reference (see GH-31736).
110+ void append_array (Vector<T> p_other);
108111
109112 _FORCE_INLINE_ bool has (const T &p_val) const { return find (p_val) != -1 ; }
110113
@@ -301,7 +304,7 @@ void Vector<T>::reverse() {
301304}
302305
303306template <typename T>
304- void Vector<T>::append_array(const Vector<T> & p_other) {
307+ void Vector<T>::append_array(Vector<T> p_other) {
305308 const Size ds = p_other.size ();
306309 if (ds == 0 ) {
307310 return ;
0 commit comments