As an exercise, I am implementing my own versions of the STL containers std::vector and std::string. When implementing my version of the following insert method
void insert (iterator position, InputIterator first, InputIterator last);
I would like to check that the input iterators first and last refer to the same container. I know that the STL containers carry out such a check, since if one tries to use insert when this condition fails, one gets an error, e.g., "string iterators incompatible". How is this check implemented for STL containers?