Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3298 closed Bugs (duplicate)

Iterating over a map fails to compile with MSVC 9 (works with CYGWIN GCC 4.3.2)

Reported by: Marshall Galbraith <Marshall.Galbraith@…> Owned by: Aleksey Gurtovoy
Milestone: Boost 1.40.0 Component: mpl
Version: Boost 1.39.0 Severity: Showstopper
Keywords: map Cc:

Description

I have written a template metafunction that takes two maps and joins them into a single map. However, if keys are erased from both maps before joining them, the iterators of the joined map fail to compile with MSVC 9. The code compiles with CYGWIN GCC 4.3.2. If a key is erased from only one of the original maps, the code compiles with both compilers.

Attachments (2)

join_map_test.cpp (4.4 KB ) - added by Marshall Galbraith <Marshall.Galbraith@…> 13 years ago.
Example code that compiles with CYGWIN GCC 4.3.2 but now MSVC 9
join_map_test_2.cpp (3.8 KB ) - added by Marshall Galbraith 13 years ago.
Updated example using MPL functions to join maps

Download all attachments as: .zip

Change History (7)

by Marshall Galbraith <Marshall.Galbraith@…>, 13 years ago

Attachment: join_map_test.cpp added

Example code that compiles with CYGWIN GCC 4.3.2 but now MSVC 9

comment:1 by Marshall Galbraith, 13 years ago

First I want to acknowledge that I am an MPL novice, and am still learning the ropes of this extremely useful library. I have attached an updated example of the problem. This implementation takes better advantage of the tools provided in the mpl library.

I have two template meta functions defined in this example which joins two maps, MapL and MapR. The first function, join_maps_1, generates a new copy of the joint maps using copy and joint_view. If I understand things correctly, this requires size<MapL> + size<MapR> instantiations. This version seems to work without problems.

The second function, join_maps_2, inserts MapR into MapL using copy<>. It should require size<MapL> instantiations. However, if the resulting map is passed to for_each<>, the code fails to compile with MSVC 9 if a key has been erase from MapL.

by Marshall Galbraith, 13 years ago

Attachment: join_map_test_2.cpp added

Updated example using MPL functions to join maps

comment:2 by Steven Watanabe, 13 years ago

This sounds like a result of #2042. Does the patch there fix your problem?

comment:3 by Marshall Galbraith, 13 years ago

Resolution: duplicate
Status: newclosed

This patch did indeed resolve the problem. I apologize for not discovering it on my own.

Is there a reason why the patch has not made it into the main repository?

in reply to:  3 ; comment:4 by Steven Watanabe, 13 years ago

Replying to Marshall Galbraith:

Is there a reason why the patch has not made it into the main repository?

I'll try to get it in soon, but it's probably too late for 1.40.

in reply to:  4 comment:5 by Aleksey Gurtovoy, 13 years ago

Replying to steven_watanabe:

Replying to Marshall Galbraith:

Is there a reason why the patch has not made it into the main repository?

I'll try to get it in soon, but it's probably too late for 1.40.

I've just merged Steven's fix to the release branch, so it should make it to 1.40 after all.

Note: See TracTickets for help on using tickets.