Re: problem: returned iterator is valid but the std:list is empty
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Fri, 09 Jun 2006 14:04:44 -0500
On Fri, 9 Jun 2006 09:56:01 -0700, Jaime Stuardo
<JaimeStuardo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi all...
I have a strange problem...
I have this code in a destructor :
for( std::list<COraDatabase *>::iterator it = m_listDB.begin(); it !=
m_listDB.end(); it++ )
delete (*it);
Where m_listDB is of std::list<COraDatabase *> type. Before the "for",
m_listDB.size( ) returns 0. When I debug the "for", m_listDB.begin( ) retuns
an iterator that is different from m_lisDB.end( ), so execution continues
inside the "for". Of course, application crashes, because (*it) is undefined.
Do you know what is happening here? what else can I test in order to find
the explanation and the solution?
VC's std::list maintains its size as a member variable (providing O(1) size
determination which is _not_ guaranteed), so I'd say you have corrupted
your std::list object at some point, or you've somehow triggered a bug in
the compiler. What do you expect the list size to be at this point?
--
Doug Harrison
Visual C++ MVP
.
- Prev by Date: Re: stl skipping algorithms
- Next by Date: Re: stl skipping algorithms
- Previous by thread: map/multimap/wildcards
- Next by thread: Re: strange 64bit compiler diagnostics on std::vector / VC8
- Index(es):
Relevant Pages
|