tobsa / SFML-Framework

A simple and basic game engine based on SFML.
1 stars 0 forks source link

Problem with List::remove #1

Open Caerind opened 10 years ago

Caerind commented 10 years ago

Here the code you've written : //////////////////////////////////////////////////////////////////////////////// template void List::remove(const T& element) { for(auto& it = m_list.begin(); it != m_list.end();) { if(*it == element) it = m_list.erase(it); else ++it; } }

Here the error I get : ...\SFML-Framework\Gui..\Containers\List.inl|108|error: invalid initialization of non-const reference of type 'std::_List_iteratorstd::shared_ptr&' from an rvalue of type 'std::liststd::shared_ptr<sfx::GuiObject, std::allocatorstd::shared_ptr >::iterator {aka std::_List_iteratorstd::shared_ptr}'|

tobsa commented 10 years ago

Hi,

I remember encountering this problem some time ago but if I remember correctly this problem could occur with all the wrapper container classes i wrote. I haven't worked on this project in a few months (to busy with college work right now) but my plan was to complety replace all the wrapper classes I wrote and go back to use the standard container classes directly since these classes created more problems than I originally thought.

So, my suggestion is that you remove the wrapper classes and replace them with the standard container classes.