public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Jambor <jamborm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-2293] vec: Add array_slice constructors from non-const and gc vectors
Date: Tue, 30 Aug 2022 16:57:05 +0000 (GMT)	[thread overview]
Message-ID: <20220830165705.EFF9E385841A@sourceware.org> (raw)

https://gcc.gnu.org/g:15433c214df295f2281a90fcf283355b21beca0e

commit r13-2293-g15433c214df295f2281a90fcf283355b21beca0e
Author: Martin Jambor <mjambor@suse.cz>
Date:   Tue Aug 30 18:50:35 2022 +0200

    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.

Diff:
---
 gcc/vec.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gcc/vec.h b/gcc/vec.h
index d048fa54ce8..1abe777baeb 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; }

                 reply	other threads:[~2022-08-30 16:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220830165705.EFF9E385841A@sourceware.org \
    --to=jamborm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).