M
matt.elkins
Hello,
Consider the following situation:
std::list <int> numbers;
numbers.push_back(5);
int * ptr = &(*(numbers.begin()));
// Work on the list
numbers.push_back(7);
numbers.push_back(12);
// etc.
My question is: will ptr always point to valid memory provided the
only operations performed on the list are to add to it (and ptr isn't
reassigned, etc)? Given the obvious implementation of a linked list,
then yes, but is it actually guaranteed (implicitly or otherwise) by
the standard?
Thanks!
Consider the following situation:
std::list <int> numbers;
numbers.push_back(5);
int * ptr = &(*(numbers.begin()));
// Work on the list
numbers.push_back(7);
numbers.push_back(12);
// etc.
My question is: will ptr always point to valid memory provided the
only operations performed on the list are to add to it (and ptr isn't
reassigned, etc)? Given the obvious implementation of a linked list,
then yes, but is it actually guaranteed (implicitly or otherwise) by
the standard?
Thanks!