#include "mseivector.h"
void main(int argc, char* argv[]) {
mse::ivector<int> v = { 1, 2, 3, 4 };
auto ip1 = v.begin();
ip1 += 2;
assert(3 == (*ip1));
auto ip2 = v.begin();
v.erase(ip2); /* remove the first item */
assert(3 == (*ip1)); /* ip1 continues to point to the same item,
not the same position */
ip1--;
assert(2 == (*ip1));
for (auto cip = v.cbegin(); v.cend() != cip; cip++) {
/* You might imagine what would happen if cip were a regular
vector iterator. */
v.insert(v.begin(), (*cip));
}
/* Btw, the iterators are compatible with stl algorithms, like any
other stl iterators. */
std::sort(v.begin(), v.end());
}
Comments