Here is some working code:
std::pair<typename std::map< time_t, T >::iterator, bool> ret;
ret = prt_map->insert ( std::pair< time_t, T >( seconds , value ) );
if (ret.second == false) // exists
{
... update exising value
}
I want to upgrade it to max efficient inserting code and give a tip to insert that need to start from –prt_map->end(); something like:
prt_map->insert ( --prt_map->end(), std::pair< time_t, T >( seconds , value ) );
but this insert function prototupe does not return std::pair with bool that notify that value added or not ( to check for existing and update if so… How to solve this to have ability to update existing value?
The post condition of a.insert(hint, t) is:
which should be sufficient information to determine whether or not the element was inserted.