In ptr_map, const_iterator does not represent value_type. Given this map:
typedef boost::ptr_map BOOSTMAP;
BOOSTMAP::value_type equates to:
boost::ptr_container_detail::ref_pair
BOOSTMAP::iterator does return this, but const_iterator returns:
boost::ptr_container_detail::ref_pair which is
unlike std::map which represents const value_type for const_iterator. Since
this is a different structure, it's incompatible with BOOSTMAP::value_type.
The following code works using std::map:
typedef std::map STDMAP;
int sample = 5;
STDMAP sm;
sm.insert( STDMAP::value_type(10,&sample) );
STDMAP::iterator sfirst = sm.begin();
STDMAP::const_iterator scfirst = sm.begin();
STDMAP::value_type& svt = *sfirst;
const STDMAP::value_type& scvt = *scfirst;
But, the same fails on the last line with boost::ptr_map
typedef boost::ptr_map BOOSTMAP;
BOOSTMAP bm;
DWORD key = 10;
bm.insert( key, new int(5) );
BOOSTMAP::iterator bfirst = bm.begin();
BOOSTMAP::const_iterator bcfirst = bm.begin();
BOOSTMAP::value_type& bvt = *bfirst;
const BOOSTMAP::value_type& bcvt = *bcfirst;
Also, it is not possible to bind to one of the members BOOSTMAP::value_type.
For example, this works with std::map, but fails with ptr_map:
boost::bind( &BOOSTMAP::value_type::first, _1 );
-- Bill --