mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
SmallVector: Don't rely on having an assignment operator around in push_back for POD-like types.
llvm-svn: 155791
This commit is contained in:
parent
9769cec353
commit
74da5acd41
@ -252,7 +252,7 @@ public:
|
||||
void push_back(const T &Elt) {
|
||||
if (this->EndX < this->CapacityX) {
|
||||
Retry:
|
||||
*this->end() = Elt;
|
||||
memcpy(this->end(), &Elt, sizeof(T));
|
||||
this->setEnd(this->end()+1);
|
||||
return;
|
||||
}
|
||||
|
@ -413,4 +413,17 @@ TEST_F(SmallVectorTest, IteratorTest) {
|
||||
theVector.insert(theVector.end(), L.begin(), L.end());
|
||||
}
|
||||
|
||||
struct notassignable {
|
||||
int &x;
|
||||
notassignable(int &x) : x(x) {}
|
||||
};
|
||||
|
||||
TEST_F(SmallVectorTest, NoAssignTest) {
|
||||
int x = 0;
|
||||
SmallVector<notassignable, 2> vec;
|
||||
vec.push_back(notassignable(x));
|
||||
x = 42;
|
||||
EXPECT_EQ(42, vec.pop_back_val().x);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user