Boost logo

Boost Users :

Subject: Re: [Boost-users] success of a multi-index container insertion
From: Igor R (boost.lists_at_[hidden])
Date: 2009-04-04 15:15:22


> As I need to know if a insertion in my multi-index container succeded or
> not I've asked me and now you: How can I get a bool from inserting a new
> object?
>
> My problem:
>
> MyMultiIndex mmi;
> MyClass mc0;
> MyClass mc1 = mc0;
> mmi.insert(mc0); // mc0 inserted
> mmi.insert(mc1); // mc1 not inserted

http://www.boost.org/doc/libs/1_38_0/libs/multi_index/doc/reference/ord_indices.html#modifiers

"std::pair<iterator,bool> insert(const value_type& x);

Returns: The return value is a pair p. p.second is true if and only if
insertion took place. On successful insertion, p.first points to the
element inserted; otherwise, p.first points to an element that caused
the insertion to be banned. Note that more than one element can be
causing insertion not to be allowed."


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net