Opened 11 years ago
Last modified 6 years ago
#6089 new Bugs
Non const & used in ptr_map::insert
Reported by: | Owned by: | Thorsten Ottosen | |
---|---|---|---|
Milestone: | To Be Determined | Component: | ptr_container |
Version: | Boost 1.48.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The boost::ptr_map inserter takes a "key_type &" rather than a "const key_type &." This is annoying if you have a function that takes a const &. I've attached a patch which should fix the problem.
Attachments (1)
Change History (4)
by , 11 years ago
comment:2 by , 6 years ago
Still there is 1.62.0 and causes the most basic examples of ptr_map to fail to compile. For instance:
boost::ptr_map<int, int> m; m.insert(0, new int(5));
It's literally a one word change to fix this.
comment:3 by , 6 years ago
I believe this is actually a feature, see www.boost.org/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 for a rationale.
A patch which fixes the problem.