[ptr_container] associative container insert takes reference instead of const reference as key ?
Hello , I've found that ptr_unordered_map.insert has following
signature (from code and latest doc)
std::pair
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
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-do... regards -Thorsten
Thank you for the explanation, I missed the FAQ part
On Wed, Aug 29, 2018 at 4:25 PM Thorsten Ottosen via Boost
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
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-do...
regards
-Thorsten
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thanks for the explanation, but if Key is POD type, we still can not
using const reference ?
regards
-
On Wed, Aug 29, 2018 at 4:25 PM Thorsten Ottosen via Boost
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
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-do...
regards
-Thorsten
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Den 29-08-2018 kl. 12:10 skrev comic fans:
Thanks for the explanation, but if Key is POD type, we still can not using const reference ? yeah, I guess one could put an overload via enable_if if the copy-constructor was noexcept.
-T -- Best regards, Thorsten Jørgen Ottosen, Ph.D. Director of Research +45 23308797 Dezide (www.dezide.com)
ok, I may take a try
regards
On Wed, Aug 29, 2018 at 6:52 PM Thorsten Ottosen
Den 29-08-2018 kl. 12:10 skrev comic fans:
Thanks for the explanation, but if Key is POD type, we still can not using const reference ? yeah, I guess one could put an overload via enable_if if the copy-constructor was noexcept.
-T
-- Best regards, Thorsten Jørgen Ottosen, Ph.D. Director of Research +45 23308797 Dezide (www.dezide.com)
participants (2)
-
comic fans
-
Thorsten Ottosen