QVarLengthArray: provide STL-compatible member function names
authorMarc Mutz <marc.mutz@kdab.com>
Thu, 24 May 2012 06:35:39 +0000 (08:35 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 19 Sep 2012 17:54:44 +0000 (19:54 +0200)
This allows, among other things, to use QVarLengthArray as the target of
a std::back_insert_iterator.

Change-Id: I507f612a23da854bf865780aa0a7e6312f4a896b
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qvarlengtharray.h
src/corelib/tools/qvarlengtharray.qdoc

index ba24541..9d52da8 100644 (file)
@@ -172,6 +172,15 @@ public:
     iterator erase(const_iterator begin, const_iterator end);
     inline iterator erase(const_iterator pos) { return erase(pos, pos+1); }
 
+    // STL compatibility:
+    inline bool empty() const { return isEmpty(); }
+    inline void push_back(const T &t) { append(t); }
+    inline void pop_back() { removeLast(); }
+    inline T &front() { return first(); }
+    inline const T &front() const { return first(); }
+    inline T &back() { return last(); }
+    inline const T &back() const { return last(); }
+
 private:
     friend class QPodList<T, Prealloc>;
     void realloc(int size, int alloc);
index 45eab98..05e16d6 100644 (file)
     \overload
 */
 
+/*! \fn T& QVarLengthArray::front()
+    \since 5.0
+
+    Same as first(). Provided for STL-compatibility.
+*/
+
+/*! \fn const T& QVarLengthArray::front() const
+    \since 5.0
+
+    \overload
+*/
+
 /*! \fn T& QVarLengthArray::last()
 
     Returns a reference to the last item in the array.  The array must
     \overload
 */
 
+/*! \fn T& QVarLengthArray::back()
+    \since 5.0
 
+    Same as last(). Provided for STL-compatibility.
+*/
+
+/*! \fn const T& QVarLengthArray::back() const
+    \since 5.0
+
+    \overload
+*/
 
 /*! \fn bool QVarLengthArray::isEmpty() const
 
     \sa size(), resize()
 */
 
+/*! \fn bool QVarLengthArray::empty() const
+    \since 5.0
+
+    Same as isEmpty(). Provided for STL-compatibility.
+*/
+
 /*! \fn void QVarLengthArray::clear()
 
     Removes all the elements from the array.
     \sa removeLast()
 */
 
+/*!
+    \fn void QVarLengthArray::push_back(const T &t)
+    \since 5.0
+
+    Same as append(). Provided for STL-compatibility.
+*/
 
 /*!
     \fn inline void QVarLengthArray::removeLast()
 */
 
 /*!
+    \fn void QVarLengthArray::pop_back()
+    \since 5.0
+
+    Same as removeLast(). Provided for STL-compatibility.
+*/
+
+/*!
     \fn void QVarLengthArray::append(const T *buf, int size)
 
     Appends \a size amount of items referenced by \a buf to this array.