list<LIGHT> m_Lights;
list<LIGHT::iterator iter;
bool AddLight(const LIGHT *pLight)
AddLight(&(*iter));
list<LIGHT> m_Lights;
list<LIGHT::iterator iter;
bool AddLight(const LIGHT *pLight)
AddLight(&(*iter));
Quote:&(*iter)
Quote:Original post by rip-off
The need to keep a list of iterators is a bit odd, can you explain that a little?
Other than that, the main danger is if lights are removed from the container. This will invalidate an iterator pointing at that light, and obviously any pointers to it.
How are you going to keep the two lists in sync, to prevent this?
If you store the pointer in AddLight(), how will you keep it in sync?
Quote:Original post by Sneftel
This is a common idiom. It pays to remember which of the standard containers may move elements around in memory: vector may; list, map/set, and deque do not.
Quote:
Isn't it slow? Does *iter copies the iterator content into a temporary buffer before passing it's address?
Quote:Original post by SneftelQuote:&(*iter)
This is a common idiom. It pays to remember which of the standard containers may move elements around in memory: vector may; list, map/set, and deque do not.