From 630f7ba9928d0cd9a6e80a0635269dc83c9ecd64 Mon Sep 17 00:00:00 2001 From: Doug Gilbert Date: Mon, 5 Mar 2012 17:24:31 -0600 Subject: Add return of an iterator to the vector erase function to match the stl standard. Change-Id: I383a147976bb6203f6426c22279f9ad6dc80b46e RTC: 37922 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/722 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III Reviewed-by: Bradley W. Bishop --- src/include/vector | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/include/vector') diff --git a/src/include/vector b/src/include/vector index 4d52d8a44..4827116dc 100644 --- a/src/include/vector +++ b/src/include/vector @@ -505,24 +505,30 @@ namespace std /** * Remove an element from the container * @param[in] position iterator, position of element to remove + * @return new location of the element that followed the last + * element erased, or end() if the operation erased + * the last element in the sequence. * @pre begin() <= position < end() * @post All previously obtained iterators are invalid. */ __attribute__ ((always_inline)) - void erase(iterator position) + iterator erase(iterator position) { - erase(position,position+1); + return erase(position,position+1); } /** * Remove a slice of elements from the container * @param[in] first iterator, postion of the first element to remove * @param[in] last iterator, postion of the last element + 1 to remove + * @return new location of the element that followed the last + * element erased, or end() if the operation erased + * the last element in the sequence. * @pre begin() <= first,last <= end(), first < last. * @post All previously obtained iterators are invalid. * @note The element pointed to be last is not deleted. */ - void erase(iterator first, iterator last) + iterator erase(iterator first, iterator last) { assert(last >= first); assert(first >= iv_start); @@ -530,12 +536,13 @@ namespace std assert(last > iv_start); assert(last <= iv_finish); - first = copy(last,iv_finish,first); - while(first != iv_finish) + last = copy(last,iv_finish,first); + while(last != iv_finish) { --iv_finish; iv_finish->~T(); } + return first; } -- cgit v1.2.3