I have a map in a multithreaded app mapping a class called uuid to pointer. What I want to know if an insert operation succeeded for failed.
e.g.
_mymap.insert(hint, MyMap::value_type(entry.uuid, itemptr));
Does it throw an exception or something if it fails?
The first insert member function returns a pair whose bool component returns true if an insertion was made and false if the map already contained an element whose key had an equivalent value in the ordering, and whose iterator component returns the address where a new element was inserted or where the element was already located.
To access the iterator component of a pair pr returned by this member function, use pr.first, and to dereference it, use *(pr.first). To access the bool component of a pair pr returned by this member function, use pr.second.
The second insert member function, the hint version, returns an iterator that points to the position where the new element was inserted into the map.
Source: http://msdn.microsoft.com/en-us/library/81ac0zkz(v=vs.80).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With