_UsedListItr = find(_UsedList.front(),_UsedList.back(),p);
_FreeList.push_front(_UsedListItr);
_UsedList.erase(_UsedListItr);
My error messages listed below indicate that I''m not supplying a == operator for the object I''m storing(represented by p). The problem is that I just want to find the pointer(ie p is just a pointer and my list is filled with pointers). So essentially all I want ''find'' to do is give me an iterator to the element equal to my pointer(p)
gimp
c:\program files\microsoft visual studio\vc98\myprojects\pluggablefactory3\memorymanager.h(57) : error C2679: binary ''='' : no operator defined which takes a right-hand operand of type ''class ByteArray *'' (or there is no acceptable conversion)
c:\program files\microsoft visual studio\vc98\myprojects\pluggablefactory3\memorymanager.h(55) : while compiling class-template member function ''void __thiscall ObjectPool::Delete(class ByteArray *)''
c:\program files\microsoft visual studio\vc98\myprojects\pluggablefactory3\memorymanager.h(58) : error C2664: ''push'' : cannot convert parameter 1 from ''class std::list >::iterator'' to ''class
ByteArray *const & ''
Reason: cannot convert from ''class std::list >::iterator'' to ''class ByteArray *const ''
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
c:\program files\microsoft visual studio\vc98\myprojects\pluggablefactory3\memorymanager.h(55) : while compiling class-template member function ''void __thiscall ObjectPool::Delete(class ByteArray *)''
[STL] Moving elements between lists.
Ok, admittedly this is a simple. one. I''m trying to move elements between two lists. The element needs to be found in the first list then just pushed to the beginning of the other list:
Finding an element in the usedlist and adding to the freelist:
Chris Brodie
Perhaps you should try this:
Hope this helps
Dormeur
_UsedListItr = find(_UsedList.begin(),_UsedList.end(),p);// Instead of adding the iterator, add the element itself_FreeList.push_front(p);// And check to make sure the find returns a matchif (_UsedListItr != _UsedList.end()) { _UsedList.erase(_UsedListItr);}
Hope this helps
Dormeur
Wout "Dormeur" NeirynckThe Delta Quadrant Development Page
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement