[Boost-bugs] [Boost C++ Libraries] #1422: const_iterator does not equate to value_type (or const value_type)

Subject: [Boost-bugs] [Boost C++ Libraries] #1422: const_iterator does not equate to value_type (or const value_type)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-11-08 18:18:52


#1422: const_iterator does not equate to value_type (or const value_type)
----------------------------------------------------+-----------------------
 Reporter: Bill Buklis <boostuser_at_[hidden]> | Owner: nesotto
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: ptr_container
  Version: Boost 1.34.1 | Severity: Problem
 Keywords: ptr_map, ptr_container, const_iterator |
----------------------------------------------------+-----------------------
 In ptr_map, const_iterator does not represent value_type. Given this map:

 typedef boost::ptr_map<DWORD, int> BOOSTMAP;

 BOOSTMAP::value_type equates to:

 boost::ptr_container_detail::ref_pair<DWORD, int* const>

 BOOSTMAP::iterator does return this, but const_iterator returns:

 boost::ptr_container_detail::ref_pair<DWORD, const int* const> 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<DWORD, int*> 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<DWORD, int> 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;
 }}}

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1422>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:56 UTC