Looks like one have to keep the result of the insert
function, analyse it and behave accordingly:
typedef std::map<int, T> itmap;
typedef std::pair<itmap::iterator, bool> itinsresult;
//...
itmap m;
int i;
T t;
//...
itinsresult result = m.insert(std::make_pair(i, t));
if (result.second) // new element inserted
{
//...
}
else // element already exists
{
(*result.first).do_something();
// ...
}