Date: Mon, 8 Dec 2025 20:04:27 +0100
Regardless whether it works with certain implementations, semantically it would be strange:
-> You want to know the memory address as an iterator, the next push[ed]_back object is stored in.
- If this is possible with some containers under some conditions, I would not call it .end(), but use a different member function to return such an iterator.
- But still it would be an iterator to non-initialized memory.
- And here we are not even talking about, whether iterators are still valid after push_back in general.
If you need such a thing in some code, I would create a new container adapter that stores an empty or default-initialized object at the end of the list or deque and then moves in the actual object at that location when needed. That works independent of the implementation and independent of reserve.
Received on 2025-12-08 19:19:05
