Boost logo

Boost :

Subject: Re: [boost] [ptr_container] associative container insert takes reference instead of const reference as key ?
From: comic fans (comicfans44_at_[hidden])
Date: 2018-08-29 09:58:40


Thank you for the explanation, I missed the FAQ part
On Wed, Aug 29, 2018 at 4:25 PM Thorsten Ottosen via Boost
<boost_at_[hidden]> wrote:
>
> Den 27-08-2018 kl. 15:03 skrev comic fans via Boost:
> > Hello , I've found that ptr_unordered_map.insert has following
> > signature (from code and latest doc)
> >
> > std::pair<iterator,bool> insert( key_type& k, T* x );
> >
> > that forbids calls like ptr_unordered_map.insert( myobj->id(), myobj)
> > ,I wonder if this is by design , or some other reason ? why other
> > overload takes const key_type& k as key type? and insert always call
> > insert_impl which have const reference as key type ? any help would
> > be appreciated.
>
> It is by design.
>
> https://www.boost.org/doc/libs/1_67_0/libs/ptr_container/doc/faq.html#why-does-ptr-map-t-insert-replace-take-two-arguments-the-key-and-the-pointer-instead-of-one-std-pair-and-why-is-the-key-passed-by-non-const-reference
>
> regards
>
> -Thorsten
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk