
31 Mar
2004
31 Mar
'04
12:30 a.m.
"Joaquín Mª López Muñoz" <joaquin@tid.es> wrote in message news:4069B0EE.598AA848@tid.es...
Pavel Vozenilek ha escrito:
"JOAQUIN LOPEZ MU?Z" <joaquin@tid.es> wrote
std::set<int> s; ... boost::optional<int> oi=s.insert(10); // oi is initialized iff insertion took place.
set::insert returns pair of iterator + bool.
You're right. I meant optional<iterator>.
Also, the iterator produced by set::insert is always meaningful. If the insertion is successful then the iterator points to the just-inserted element, and the bool equals true. If the insertion is not successful then the iterator points to the element of the set that caused the insertion to fail, and the bool equals false. Joe Gottman