STL list and referencing
I have an STL list which holds references to a list of entities which are dynamic in my program. I am using an iterator to go through this list of items. I am trying to do the following which doesn't seem to be working
However when I call (*itor)->SetPosition it looks like instead of referencing its doing a copy so its not affecting the value at all. I suppose that its supposed to work that way. However I would like to know how to make the SetPosition to work.
std::list<Entity *>::iterator itor = this->m_EntitiesList.begin();
while(itor != this->m_EntitiesList.end())
vector3 view = m_pCamera->GetTarget();
(*itor)->SetPosition(view.x, 0.0f, view.y);
It looks like your problem is not with the STL list, but with your Entity class or the pointers you are adding to the list. The list holds pointers, and your code looks correct (you are properly calling functions of whichever Entity the stored pointer is pointing to). In other words, from the standpoint of using the STL, that code is fine.