Will the switch affect both vectors or just the one calling swap()?
std::vector<bool>::iterator i;
std::vector<bool>::iterator j;
j = b.begin();
for(i = a.begin();i != a.end();i++)
{
a.swap(i,j);
j++;
}
std::vector<bool>::iterator i;
std::vector<bool>::iterator j;
j = b.begin();
for(i = a.begin();i != a.end();i++)
{
a.swap(i,j);
j++;
}
std::swap(*i, *j);
a.swap(b);
If you want to swap manually, you shouldn't use vector::swap, but std::swap, like this:
std::swap(*i, *j);