2010-05-11 21:42:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 23:36:01 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <vector>
|
|
|
|
// vector<bool>
|
|
|
|
|
|
|
|
// iterator erase(const_iterator first, const_iterator last);
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
bool a1[] = {1, 0, 1};
|
|
|
|
{
|
|
|
|
std::vector<bool> l1(a1, a1+3);
|
|
|
|
std::vector<bool>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
|
|
|
|
assert(l1.size() == 3);
|
|
|
|
assert(distance(l1.cbegin(), l1.cend()) == 3);
|
|
|
|
assert(i == l1.begin());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
std::vector<bool> l1(a1, a1+3);
|
|
|
|
std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
|
|
|
|
assert(l1.size() == 2);
|
|
|
|
assert(distance(l1.cbegin(), l1.cend()) == 2);
|
|
|
|
assert(i == l1.begin());
|
|
|
|
assert(l1 == std::vector<bool>(a1+1, a1+3));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
std::vector<bool> l1(a1, a1+3);
|
|
|
|
std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
|
|
|
|
assert(l1.size() == 1);
|
|
|
|
assert(distance(l1.cbegin(), l1.cend()) == 1);
|
|
|
|
assert(i == l1.begin());
|
|
|
|
assert(l1 == std::vector<bool>(a1+2, a1+3));
|
|
|
|
}
|
|
|
|
{
|
|
|
|
std::vector<bool> l1(a1, a1+3);
|
|
|
|
std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
|
|
|
|
assert(l1.size() == 0);
|
|
|
|
assert(distance(l1.cbegin(), l1.cend()) == 0);
|
|
|
|
assert(i == l1.begin());
|
|
|
|
}
|
|
|
|
}
|