Opened 7 years ago

Closed 6 years ago

#11829 closed Bugs (fixed)

Order of elements with same key in multimap not preserved

Reported by: boost@… Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description

The hinting in load_map_collection from boost/serialization/map.hpp destroys the relative order of elements with the same key. Since C++11 one can reconstruct multimaps where the elements preserve the original order. However, one has to use the multimap insertions without hinting. A quick fix would be to drop hinting for multimaps whereas for maps it can still be used. Possibly also hinting with the end pointer would work.

Attachments (2)

mwe.cpp​ (748 bytes ) - added by boost@… 7 years ago.
Minimum working example demonstrating bug. The relative order of the elements with the same key is destroyed when restoring the multimap.
map.hpp​ (5.2 KB ) - added by boost@… 7 years ago.
A simple workaround, where hinting is dropped for multimaps.

Download all attachments as: .zip

Change History (3)

by boost@…, 7 years ago

Attachment: mwe.cpp​ added

Minimum working example demonstrating bug. The relative order of the elements with the same key is destroyed when restoring the multimap.

by boost@…, 7 years ago

Attachment: map.hpp​ added

A simple workaround, where hinting is dropped for multimaps.

comment:1 by Robert Ramey, 6 years ago

Resolution: → fixed
Status: new → closed

I'm pretty sure I've fixed this but forget about it. Please check boost 1.61

Note: See TracTickets for help on using tickets.