Subject: Re: [boost] [multi_index] scalar insert interface
From: Maxim Yegorushkin (maxim.yegorushkin_at_[hidden])
Date: 2010-11-08 05:37:17
On 05/11/10 18:15, JOAQUIN M. LOPEZ MUÃOZ wrote:
> De: boost-bounces_at_[hidden] [boost-bounces_at_[hidden]] En nombre de Stewart, Robert [Robert.Stewart_at_[hidden]]
> Enviado el: viernes, 05 de noviembre de 2010 18:54
> Para: boost_at_[hidden]
> Asunto: Re: [boost] [multi_index] scalar insert interface
>> Maxim Yegorushkin wrote:
>>> In ordered_index there are two scalar insert overloads:
>>> std::pair<iterator,bool> insert(const value_type& x);
>>> iterator insert(iterator position,const value_type& x);
>>> The second version is lacking the bool result, which is sometimes
>> As is, it mirrors std::map's interface.
> Correct, this is exactly the rationale behind the difference in the
> result types of both overloads. Clever as Maxim's suggestion is,
> I'm reluctant to diverge from the standard without a compelling
> reason --here the benefit does not seem impressive, since there
> are efficient ways to determine whether the insertion took place,
> for instance checking size() before and after trying the insertion.
That is actually a good idea to check size().
The rationale behind the patch was that internally final_insert_ still
returns that bool flag, it is just the interface of std::map::insert
requires to discard that value.
Anyway, checking size() solves my issue.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk