aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2022-08-30 18:50:35 +0200
committerMartin Jambor <mjambor@suse.cz>2022-08-30 18:56:07 +0200
commit15433c214df295f2281a90fcf283355b21beca0e (patch)
treefb40fddf0abf7af260bae9bffd97368affa88f4e
parent75f59441cd63a1d07e86d70d59c518049f53904f (diff)
downloadgcc-15433c214df295f2281a90fcf283355b21beca0e.zip
gcc-15433c214df295f2281a90fcf283355b21beca0e.tar.gz
gcc-15433c214df295f2281a90fcf283355b21beca0e.tar.bz2
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 <mjambor@suse.cz> * vec.h (array_slice): Add constructors for non-const reference to heap vector and pointers to heap vectors.
-rw-r--r--gcc/vec.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/vec.h b/gcc/vec.h
index d048fa5..1abe777 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -2267,6 +2267,18 @@ public:
array_slice (const vec<OtherT> &v)
: m_base (v.address ()), m_size (v.length ()) {}
+ template<typename OtherT>
+ array_slice (vec<OtherT> &v)
+ : m_base (v.address ()), m_size (v.length ()) {}
+
+ template<typename OtherT>
+ array_slice (const vec<OtherT, va_gc> *v)
+ : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : 0) {}
+
+ template<typename OtherT>
+ array_slice (vec<OtherT, va_gc> *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; }