From: Martin Jambor Date: Tue, 30 Aug 2022 16:50:35 +0000 (+0200) Subject: vec: Add array_slice constructors from non-const and gc vectors X-Git-Tag: basepoints/gcc-14~4914 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15433c214df295f2281a90fcf283355b21beca0e;p=thirdparty%2Fgcc.git vec: Add array_slice constructors from non-const and gc vectors This patch adds constructors of array_slice that are required to create them from non-const (heap or auto) vectors or from GC vectors. gcc/ChangeLog: 2022-08-08 Martin Jambor * vec.h (array_slice): Add constructors for non-const reference to heap vector and pointers to heap vectors. --- diff --git a/gcc/vec.h b/gcc/vec.h index d048fa54ce8a..1abe777baebb 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -2267,6 +2267,18 @@ public: array_slice (const vec &v) : m_base (v.address ()), m_size (v.length ()) {} + template + array_slice (vec &v) + : m_base (v.address ()), m_size (v.length ()) {} + + template + array_slice (const vec *v) + : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : 0) {} + + template + array_slice (vec *v) + : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : 0) {} + iterator begin () { return m_base; } iterator end () { return m_base + m_size; }