Opened 11 years ago

Last modified 6 years ago

#6089 new Bugs

Non const & used in ptr_map::insert

Reported by: jdoliner@… 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)

patch (505 bytes ) - added by jdoliner@… 11 years ago.
A patch which fixes the problem.

Download all attachments as: .zip

Change History (4)

by jdoliner@…, 11 years ago

Attachment: patch added

A patch which fixes the problem.

comment:1 by Alex Ku <alex.s.kudinov@…>, 10 years ago

still exists in 1.53.0

comment:2 by anonymous, 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 m.champlon@…, 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.

Note: See TracTickets for help on using tickets.