[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stl-vector of pointers to elements of another vector
From: |
Paul Pluzhnikov |
Subject: |
Re: stl-vector of pointers to elements of another vector |
Date: |
22 Jan 2005 13:48:47 -0800 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence) |
Ulrich Eckhardt <doomster@knuut.de> writes:
> You are doing something bad, you assume vector-iterators are pointers.
The OP can fix the problem by eliminating that assumption. Either of
the statements below will work:
testselect.push_back(&(*test_itr));
testselect.push_back(test_itr.operator->());
Also note that if you ever resize/reserve/push_back or modify
the 'testlist' vector, all of the pointers in 'testselect' become
invalid. Generally, it is not a good idea to have pointers to the
inside elements of a container which can move its elements around.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.