Is there C++ container that guarantees a fixed pointer for items what ever changes happened?
For example, std::vector may change the address of an item if a push_back or erase happened. So the address of the item will be rubbish after this change. So, is there a container that does not change items address in memory while the container changing?
P.S. compile time size or fixed size is not an option
EDIT: As @Joachim Pileborg stated it is XY problem or in actual it is XYZ one! The Z is this question. The Y is the following one: Keeping vector of iterators of the data
The original one:
I have data which is set of Points(x,y)
. This Points
will go into a pipeline. The result should be:
- set of
Lines
- set of
Points
for each line... in other word, set of set of Points
I do not want to copy the point and return them by value. I know a Point
with just x
and y
is nothing to worry about copying it. However, in my it is templated problem which may be much bigger object in some cases.