
On 05/11/10 18:15, JOAQUIN M. LOPEZ MUÑOZ wrote:
________________________________________ De: boost-bounces@lists.boost.org [boost-bounces@lists.boost.org] En nombre de Stewart, Robert [Robert.Stewart@sig.com] Enviado el: viernes, 05 de noviembre de 2010 18:54 Para: boost@lists.boost.org 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 required.
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.
Performance-wise, it probably requires extra CPU cycles and storage (cache) to check size before and after insertion. I would still vote for another insert overload, maybe insert2() or something, which returns that bool. Since internally final_insert_ always returns it, there is no good reason to waste it. -- Max