$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Sascha Seewald (sascha.seewald_at_[hidden])
Date: 2005-11-01 08:35:08
Hi Boosters!
I've been playing around with BOOST_FOREACH a little and got 
some unexpected results. The following program crashes when 
I try to iterate a const map with BOOST_FOREACH. That's 
really strange because for the non-const map everything 
works fine.
Please take a look at the source. What's wrong here? Did I 
miss something?
This is the version in cvs on vc-8_0.
Cheers
Sascha
-----------------------------------------------------------------
<source>
#include <boost/foreach.hpp>
#include <map>
class foo
{	
public:
   typedef	std::map<int, float>	map_type;
   /// return copy of map
   map_type 		map() const { return _map; }
   /// return const copy of map
   map_type const	map_c() const { return _map; }
private:	
   map_type		_map;
};
void main()
{		
   foo f;	
   // iterate copy ... ok
   BOOST_FOREACH( foo::map_type::value_type i, f.map() ) {}	
        
   // iterate const copy ... crashes here! :-(
   BOOST_FOREACH( foo::map_type::value_type i, f.map_c() ) {}
}
</source>