mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-18 14:31:27 +00:00
SmallVector: Don't rely on having an assignment operator around in push_back for POD-like types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155791 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bbd8e5d79a
commit
3703baacf5
@ -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…
x
Reference in New Issue
Block a user