Is inserting an element of a std::vector into the same vector allowed?
Consider the following insert and emplace member functions of std::vector<T> : template <class... Args> iterator emplace(const_iterator position, Args&&... args); iterator insert(const_iterator position, const T& x); iterator insert(const_iterator position, T&& x); iterator insert(const_iterator position, size_type n, const T& x); What if one of them is invoked with a reference to an element of the vector itself as an argument? Normally, each of them invalidates references to all elements starting from position , which might include the argument, or if a reallocation happens, references to all