It works, yes, but it is not an ideal approach.
Firstly, adding 0 is just noise, you can remove it. But even better, just use it pop_front(). In addition, there is no need for an intermediate step, you can delete it before deleting.
But std::vectornot as good as jumping out from the front, especially if it is large (because the rest of the elements need to be moved to fill the void). If you do not need continuous memory, use instead std::deque. Or, if the order doesn't matter, you can use something like this:
template <typename T, typename A>
void unordered_pop_front(std::vector<T, A>& vec)
{
using std::swap;
swap(vec.front(), vec.back());
vec.pop_back();
}
, . , .
. , , - . .
Boost ptr_vector std::vector . (: std::auto_ptr , .) std::unique_ptr ( ++ 0x), std::/boost::shared_ptr.