M
Matthias Kaeppler
Hi,
I have a question regarding references, and their chance to "dangle" (if
that's possible at all):
Say I have a collection ob objects, and I take a reference to one of
them. Now I sort this collection, or invoke whatever action it takes to
copy around the elements in the collection.
What happens to the reference?
Example:
class A {};
int main()
{
list<A> coll;
// ... add elements to coll
A &ref = *(coll.begin());
coll.sort(); // assume that referenced element gets copied around
// at this point, is 'ref' dangling or is it still valid?
}
I have a question regarding references, and their chance to "dangle" (if
that's possible at all):
Say I have a collection ob objects, and I take a reference to one of
them. Now I sort this collection, or invoke whatever action it takes to
copy around the elements in the collection.
What happens to the reference?
Example:
class A {};
int main()
{
list<A> coll;
// ... add elements to coll
A &ref = *(coll.begin());
coll.sort(); // assume that referenced element gets copied around
// at this point, is 'ref' dangling or is it still valid?
}