]> gcc.gnu.org Git - gcc.git/commitdiff
vec: Add array_slice constructors from non-const and gc vectors
authorMartin Jambor <mjambor@suse.cz>
Tue, 30 Aug 2022 16:50:35 +0000 (18:50 +0200)
committerMartin Jambor <mjambor@suse.cz>
Tue, 30 Aug 2022 16:56:07 +0000 (18:56 +0200)
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.

gcc/vec.h

index d048fa54ce8a69c73e4de56cc598acbc91a65cd3..1abe777baebb50b8f1caaae42a71ecc1f4953577 100644 (file)
--- 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; }
 
This page took 0.059578 seconds and 5 git commands to generate.