aboutsummaryrefslogtreecommitdiff
path: root/gcc/vec.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/vec.h')
-rw-r--r--gcc/vec.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/vec.h b/gcc/vec.h
index eae4b0f..7e112d1 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -611,6 +611,7 @@ public:
const T *end () const { return address () + length (); }
const T &operator[] (unsigned) const;
T &operator[] (unsigned);
+ const T &last (void) const;
T &last (void);
bool space (unsigned) const;
bool iterate (unsigned, T *) const;
@@ -915,6 +916,14 @@ vec<T, A, vl_embed>::operator[] (unsigned ix)
/* Get the final element of the vector, which must not be empty. */
template<typename T, typename A>
+inline const T &
+vec<T, A, vl_embed>::last (void) const
+{
+ gcc_checking_assert (m_vecpfx.m_num > 0);
+ return (*this)[m_vecpfx.m_num - 1];
+}
+
+template<typename T, typename A>
inline T &
vec<T, A, vl_embed>::last (void)
{
@@ -1588,6 +1597,8 @@ public:
const T *end () const { return begin () + length (); }
const T &operator[] (unsigned ix) const
{ return (*m_vec)[ix]; }
+ const T &last (void) const
+ { return m_vec->last (); }
bool operator!=(const vec &other) const
{ return !(*this == other); }