Previously we used the SmallVector(size_t Size, const T& Value) constructor
with a default constructed Value. That will copy construct every element
in the vector, but not all types can be copy constructed.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D147426
this->destroy_range(this->begin(), this->end());
}
- explicit SmallVector(size_t Size, const T &Value = T())
+ explicit SmallVector(size_t Size)
+ : SmallVectorImpl<T>(N) {
+ this->resize(Size);
+ }
+
+ SmallVector(size_t Size, const T &Value)
: SmallVectorImpl<T>(N) {
this->assign(Size, Value);
}
V.resize(42);
}
+TEST(SmallVectorTest, ConstructNonCopyableTest) {
+ SmallVector<NonCopyable, 0> V(42);
+ EXPECT_EQ(V.size(), 42);
+}
+
// Assert that v contains the specified values, in order.
template <typename VectorT>
void assertValuesInOrder(VectorT &v, size_t size, ...) {