Overview
Features
Download
Documentation
Community
Add-Ons & Services

HashMap.erase(Iterator it) makes "it"'s value uncertain?

Please post support and help requests here.

HashMap.erase(Iterator it) makes "it"'s value uncertain?

Postby Poechant » 18 Jun 2012, 13:06

Code: Select all
Poco::HashMap<std::string, MediaConnector*>::Iterator it = myMap.find(key);
myMap.erase(it);
std::cout << it->first << " " << it->second << std::endl;


I find that
Code: Select all
it->first
and
Code: Select all
it->second
could generate correct values generally.
But sometimes
Code: Select all
it->first
and
Code: Select all
it->second
are uncertain values or undefined staffs.

That is to say, it's not reliable to use the iterator after using it as a parameter in the HashMap::erase(Iterator it) function, right?
Poechant
 
Posts: 1
Joined: 18 Jun 2012, 12:58

Re: HashMap.erase(Iterator it) makes "it"'s value uncertain?

Postby alex » 19 Jun 2012, 13:22

Poechant wrote:it's not reliable to use the iterator after using it as a parameter in the HashMap::erase(Iterator it) function, right?

Right.
alex
 
Posts: 1122
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests