Re: [boost] Index_set observations

----- Mensaje original ----- De: Shannon Stewman <stew@uchicago.edu> Fecha: Lunes, Marzo 29, 2004 10:33 pm Asunto: Re: [boost] Index_set observations
On Mon, Mar 29, 2004 at 08:14:09AM +0200, Joaqu?n M? L?pez Mu?oz wrote:
If the insertion violates some constraint, then it does not take place. insert operations return a pair<iterator,bool>: the bool indicates whether insertion succeeded or not.
Forgive me if this has already been asked, but why don't you return a boost::optional<> object?
It has not been asked before. The only reason is that this is how STL containers (like std::set) do it. But this raises an interesting possibility. Maybe optional<T> can be augmented with a ctor accepting an std::pair<T,bool>. I'll post this in a separate thread. Thanks, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

JOAQUIN LOPEZ MU?Z wrote:
----- Mensaje original ----- De: Shannon Stewman <stew@uchicago.edu> Fecha: Lunes, Marzo 29, 2004 10:33 pm Asunto: Re: [boost] Index_set observations
On Mon, Mar 29, 2004 at 08:14:09AM +0200, Joaqu?n M? L?pez Mu?oz wrote:
If the insertion violates some constraint, then it does not take place. insert operations return a pair<iterator,bool>: the bool indicates whether insertion succeeded or not.
Forgive me if this has already been asked, but why don't you return a boost::optional<> object?
It has not been asked before. The only reason is that this is how STL containers (like std::set) do it.
STL containers return pair<iterator, bool>, because the iterator return is not optional, it's always valid and useful. optional<iterator> is not the same as pair<iterator, bool>.
participants (2)
-
JOAQUIN LOPEZ MU?Z
-
Peter Dimov