Bug fixes: assignment operator forgot to copy over size; copy ctor forgot to clear...
[oota-llvm.git] / include / llvm / ADT / SmallVector.h
index 94817edeee5c4dc83e6876e3cb1c358be9ffb02f..b5ee6c454b3088e0b6e04b07963dfbad15bef357 100644 (file)
@@ -275,8 +275,8 @@ private:
   
   void destroy_range(T *S, T *E) {
     while (S != E) {
-      E->~T();
       --E;
+      E->~T();
     }
   }
 };
@@ -418,6 +418,13 @@ public:
   SmallVector() : SmallVectorImpl<T>(NumTsAvailable) {
   }
   
+  SmallVector(unsigned Size, const T &Value)
+    : SmallVectorImpl<T>(NumTsAvailable) {
+    this->reserve(Size);
+    while (Size--)
+      push_back(Value);
+  }
+  
   template<typename ItTy>
   SmallVector(ItTy S, ItTy E) : SmallVectorImpl<T>(NumTsAvailable) {
     append(S, E);