this->grow();
I = this->begin()+EltNo;
}
- ::new ((void*) this->end()) T(this->back());
- this->setEnd(this->end()+1);
+ ::new ((void*) this->end()) T(std::move(this->back()));
// Push everything else over.
this->move_backward(I, this->end()-1, this->end());
+ this->setEnd(this->end()+1);
// If we just moved the element we're inserting, be sure to update
// the reference.
}
Constructable(const Constructable & src) : constructed(true) {
+ EXPECT_TRUE(src.constructed);
value = src.value;
++numConstructorCalls;
}
Constructable(Constructable && src) : constructed(true) {
+ EXPECT_TRUE(src.constructed);
value = src.value;
+ src.value = -1;
++numConstructorCalls;
}
Constructable & operator=(const Constructable & src) {
EXPECT_TRUE(constructed);
+ EXPECT_TRUE(src.constructed);
value = src.value;
++numAssignmentCalls;
return *this;
Constructable & operator=(Constructable && src) {
EXPECT_TRUE(constructed);
+ EXPECT_TRUE(src.constructed);
value = src.value;
+ src.value = -1;
++numAssignmentCalls;
return *this;
}
this->assertValuesInOrder(this->theVector, 4u, 1, 77, 2, 3);
}
+// Insert a copy of a single element.
+TYPED_TEST(SmallVectorTest, InsertCopy) {
+ SCOPED_TRACE("InsertTest");
+
+ this->makeSequence(this->theVector, 1, 3);
+ Constructable C(77);
+ typename TypeParam::iterator I =
+ this->theVector.insert(this->theVector.begin() + 1, C);
+ EXPECT_EQ(this->theVector.begin() + 1, I);
+ this->assertValuesInOrder(this->theVector, 4u, 1, 77, 2, 3);
+}
+
// Insert repeated elements.
TYPED_TEST(SmallVectorTest, InsertRepeatedTest) {
SCOPED_TRACE("InsertRepeatedTest");