forked from OSchip/llvm-project
[ADT] C++11ify SmallVector::erase's arguments from iterator to const_iterator
llvm-svn: 264330
This commit is contained in:
parent
df9ae70f49
commit
6ae4bc8958
|
@ -356,6 +356,7 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T, isPodLike<T>::value> {
|
|||
SmallVectorImpl(const SmallVectorImpl&) = delete;
|
||||
public:
|
||||
typedef typename SuperClass::iterator iterator;
|
||||
typedef typename SuperClass::const_iterator const_iterator;
|
||||
typedef typename SuperClass::size_type size_type;
|
||||
|
||||
protected:
|
||||
|
@ -459,7 +460,10 @@ public:
|
|||
append(IL);
|
||||
}
|
||||
|
||||
iterator erase(iterator I) {
|
||||
iterator erase(const_iterator CI) {
|
||||
// Just cast away constness because this is a non-const member function.
|
||||
iterator I = const_cast<iterator>(CI);
|
||||
|
||||
assert(I >= this->begin() && "Iterator to erase is out of bounds.");
|
||||
assert(I < this->end() && "Erasing at past-the-end iterator.");
|
||||
|
||||
|
@ -471,7 +475,11 @@ public:
|
|||
return(N);
|
||||
}
|
||||
|
||||
iterator erase(iterator S, iterator E) {
|
||||
iterator erase(const_iterator CS, const_iterator CE) {
|
||||
// Just cast away constness because this is a non-const member function.
|
||||
iterator S = const_cast<iterator>(CS);
|
||||
iterator E = const_cast<iterator>(CE);
|
||||
|
||||
assert(S >= this->begin() && "Range to erase is out of bounds.");
|
||||
assert(S <= E && "Trying to erase invalid range.");
|
||||
assert(E <= this->end() && "Trying to erase past the end.");
|
||||
|
|
|
@ -459,7 +459,8 @@ TYPED_TEST(SmallVectorTest, EraseTest) {
|
|||
SCOPED_TRACE("EraseTest");
|
||||
|
||||
this->makeSequence(this->theVector, 1, 3);
|
||||
this->theVector.erase(this->theVector.begin());
|
||||
const auto &theConstVector = this->theVector;
|
||||
this->theVector.erase(theConstVector.begin());
|
||||
this->assertValuesInOrder(this->theVector, 2u, 2, 3);
|
||||
}
|
||||
|
||||
|
@ -468,7 +469,8 @@ TYPED_TEST(SmallVectorTest, EraseRangeTest) {
|
|||
SCOPED_TRACE("EraseRangeTest");
|
||||
|
||||
this->makeSequence(this->theVector, 1, 3);
|
||||
this->theVector.erase(this->theVector.begin(), this->theVector.begin() + 2);
|
||||
const auto &theConstVector = this->theVector;
|
||||
this->theVector.erase(theConstVector.begin(), theConstVector.begin() + 2);
|
||||
this->assertValuesInOrder(this->theVector, 1u, 3);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue