   STL iterators
  Extending Enginuity''s memory manager, I''ve decided to give each IMMObject it''s own std::list iterator for faster removal.  Instead of giving each object a "bIsStackAllocated" flag, I want to have the member iterators of stack objects point to a unique IMMObject::StackIterator. Is there any way for me to make sure that this iterator will not be used, i.e. create a "null iterator" the way a "null pointer" can be used?On destruction, instead of checking a flag to see if it''s stack-allocated, then the object would check its member iterator with a known iterator instead. 
  Is this so that it will automatically remove itself from the container when its destructor is called?Each object will keep a reference to the container and its own iterator. That seems like a large overhead for every object. If all your objects are in a container and you find one of them needs deleting you can remove it from the container and delete it. It doesn''t need to be hard coded into the object itself. It seems very inflexible. If you use a smart pointer such as boost.smart_ptr you can just remove it and it will automatically be deleted. ;  No, it will flag itself to be removed, then the memory manager will remove it, then destroy the object, converting it back to raw memory.  The whole idea behind my memory management system is that each object that wants to be managed will inherit from MMObject, and so I''ve got my own smart pointer class.  I don''t want the objects to just delete themselves, I only need them to mark themselves.  So I guess that smart_ptr would work, by my supplying a deleter that only marks it for removal, but I don''t want to work with boost because I''m afraid I''ll use it far too inefficiently.Why would each object keep a reference to the container?  Having an iterator is sufficient.  I know that I can just search through the list, but why search twice when I will be looking for the iterator the first time anyway?  (I haven''t tested it, so I may not even implement it at all.) ;quote:Original post by psykr  but I don''t want to work with boost because I''m afraid I''ll use it far too inefficiently.Sounds like a great opportunity to learn, IMNSHO 