Q:

How can i implement a vector.insert like method for my custom vector class?

i have made a custom class to implement a std::vector.
My class has Forward iterator support. I'd like to know how I can implement a vector.insert like method that allows me to insert an element at any position inside the vector.
I can't use allocator, but i'd like to know if the insert method can be done with iterators and, if it is possible, how can it be done?

A:

To implement insert you need to move/copy all elements post the insertion point one element (possibly allocating new memory and moving all members if your internal storage is not large enough), then insert the new element in the "hole" you just made.
Note that this (of course) invalidates existing iterators.

