True, for primitives it would be slower. Nor can the compiler optimize the difference away.
You gain if your element type has an efficient swap. The using declaration is not necessary, because iter_swap takes care of that. (You might want to use a using declaration for iter_swap, just in case you ever exchange the vector for something else.)Quote:
So, to gain anything from it I would have to overload the swap function for my type (and use using std::swap to make it choose the overload)?
Not until we get Concepts in C+++09.Quote:
However, then there would be unnecessary overhead for types that don't / cannot implement swap efficiently. Is there a way to make fast_erase choose swapping automatically if there is a swap method present for the type and use assignment otherwise?