Gernot said:
std::deque<int> d;
d.push_front(13);
int* p13 = &d.begin();
d.push_front(1);
d.push_back(2);
Can I be safe, that p13 points to 13? I mean, unless I erase the 13,
of course.
In [23.1.1/Table 68], the standard defines the semantics of push_front() and
push_back() in terms of insert. Whether those operations invalidate
iterators, pointer, or references then depends on what insert() does. Here
is what the standard says about insert() for std::deque [23.2.1.3/1]:
iterator insert(iterator position, const T& x);
void insert(iterator position, size_type n, const T& x);
template <class InputIterator>
void insert(iterator position, InputIterator first, InputIterator last);
Effects: An insert in the middle of the deque invalidates all the
iterators and references to elements of the deque. An insert at either end
of the deque invalidates all the iterators to the deque, but has no effect
on the validity of references to elements of the deque.
Best
Kai-Uwe Bux