summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/SmallVector.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-28 05:03:42 +0000
committerChris Lattner <sabre@nondot.org>2006-07-28 05:03:42 +0000
commitd91e5f911f5fc840725771d3b27211b9748659e3 (patch)
treed9e6de68d495f2cd1b3cc97e4355226067a1ffe3 /include/llvm/ADT/SmallVector.h
parente47863e212e0af6239f6f40b2496ede29847bbce (diff)
downloadllvm-d91e5f911f5fc840725771d3b27211b9748659e3.tar.gz
llvm-d91e5f911f5fc840725771d3b27211b9748659e3.tar.bz2
llvm-d91e5f911f5fc840725771d3b27211b9748659e3.tar.xz
The smallvector dtor should destroy the elements.
Implement pop_back. Chage some code to use 'iterator' instead of T*. This unbreaks operators=. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29380 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SmallVector.h')
-rw-r--r--include/llvm/ADT/SmallVector.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h
index e542f4cd2c..6f031a82e4 100644
--- a/include/llvm/ADT/SmallVector.h
+++ b/include/llvm/ADT/SmallVector.h
@@ -66,6 +66,10 @@ public:
std::uninitialized_copy(RHS.begin(), RHS.end(), Begin);
}
~SmallVector() {
+ // Destroy the constructed elements in the vector.
+ for (iterator I = Begin, E = End; I != E; ++I)
+ I->~T();
+
// If this wasn't grown from the inline copy, deallocate the old space.
if ((void*)Begin != (void*)InlineElts)
delete[] (char*)Begin;
@@ -115,6 +119,12 @@ public:
goto Retry;
}
+ void pop_back() {
+ assert(!empty() && "SmallVector is empty!");
+ --End;
+ End->~T();
+ }
+
/// append - Add the specified range to the end of the SmallVector.
///
template<typename in_iter>
@@ -154,7 +164,7 @@ public:
// This allows us to avoid copying them during the grow.
if (Capacity-Begin < RHSSize) {
// Destroy current elements.
- for (T *I = Begin, E = End; I != E; ++I)
+ for (iterator I = Begin, E = End; I != E; ++I)
I->~T();
End = Begin;
CurSize = 0;
@@ -192,7 +202,7 @@ private:
std::uninitialized_copy(Begin, End, NewElts);
// Destroy the original elements.
- for (T *I = Begin, *E = End; I != E; ++I)
+ for (iterator I = Begin, E = End; I != E; ++I)
I->~T();
// If this wasn't grown from the inline copy, deallocate the old space.