Hello.
I am aware that adding and removing objects from vector will at some point cause it to "resize" and therefore replace its position in memory in some cases.
I have a vector that stores unique_ptr of my object and there are gonna be ranging from 1-? , and they are only defied at runtime and are resized during runtime.
as so:
std::vector<std::unique_ptr<my_class>> list;
What i need is to make a pointer or reference to first object somewhere else in the code.
I am afraid that setting it simply like this:
my_class * obj_foo;
obj_foo = list[0].get();
is not bullet proof.
Question: Will the "obj_foo" to go corrupt at some point, and not point to the first object in the vector(since vector will move it self to place where it has enough memory place).
Or am i wrong? is that the case?
NOTE: I tested it, and it seamed to keep the pointer intact but dosen't hurt to ask.