> In such a mindset passing pointers around without an accompanying end iterator, or iteration count, just makes no sense. Anywhere that implied iteration count is always a constant, I'm probably not structuring my code correctly.
Passing around two iterators is still not safe, due to iterator invalidation.
Memory safety in the C++ model is a hard problem.
> So my recommendation is to use references (foo&) for passing down (well, up) the stack, never to heap allocated objects.
I don't think this is practical. Consider `operator[]` on a vector, which returns a reference to a heap allocated object. If that were to copy out, you'd have a lot of overhead, and if it were to move, then a lot of very common patterns would be annoying to write.
Passing around two iterators is still not safe, due to iterator invalidation.
Memory safety in the C++ model is a hard problem.
> So my recommendation is to use references (foo&) for passing down (well, up) the stack, never to heap allocated objects.
I don't think this is practical. Consider `operator[]` on a vector, which returns a reference to a heap allocated object. If that were to copy out, you'd have a lot of overhead, and if it were to move, then a lot of very common patterns would be annoying to write.