Opened 8 years ago

Last modified 8 years ago

#10370 new Bugs

Iterating over ptr_map type is largely broken in 1.56

Reported by: scottbgoldblatt@… Owned by: Thorsten Ottosen
Milestone: To Be Determined Component: ptr_container
Version: Boost 1.56.0 Severity: Showstopper
Keywords: ptr_map Cc:

Description

Iteration over map fails on most types, except for value. Not sure which version this failure began, but definitely present in 1.56

The following simple snippet will fail:

typedef boost::ptr_map<int, int> test_map_type; test_map_type test_map;

BOOST_FOREACH(test_map_type::const_reference r, test_vector ) {

}

Will also fail with reference, iterator, const_iterator. boost::tie also fails. Can iterate by value, but this does not help with my application since the mapped type will be an abstract type (so no clone allocator for mapped type)

Change History (3)

comment:1 by Eric Niebler, 8 years ago

Component: foreachptr_container
Keywords: foreach removed
Owner: changed from Eric Niebler to Thorsten Ottosen

This test case shows the problem is specific to ptr_container and has nothing to do with BOOST_FOREACH.

#include <boost/ptr_container/ptr_map.hpp>

int main()
{
    typedef boost::ptr_map<int, int> test_map_type;
    test_map_type test_map;
    test_map_type::const_reference r = *test_map.begin();
}

For me, this gives:

1>f:\scratch\scratch\main.cpp(9): error C2440: 'initializing' : cannot convert from 'boost::ptr_container_detail::ref_pair<F,S>' to 'boost::ptr_container_detail::ref_pair<F,S>'
1>          with
1>          [
1>              F=int
1>  ,            S=int *const 
1>          ]
1>          and
1>          [
1>              F=int
1>  ,            S=const int *const 
1>          ]
1>          No constructor could take the source type, or constructor overload resolution was ambiguous

comment:2 by anonymous, 8 years ago

Discovered that switching compiler flag to c++11 resolved the problem. Maybe this problem is specific to GNU compiler without c++11 enabled?

comment:3 by Eric Niebler, 8 years ago

I was seeing it on msvc 2013.

Note: See TracTickets for help on using tickets.