using pairs with boost.foreach
Hi: Is it possible to use an std::pair with boost.foreach? I'm getting all sorts of errors when trying to do this. Any help appreciated.
Igor R escribió:
Is it possible to use an std::pair with boost.foreach?
typedef std::map<int, double> map_type; map_type my_map; //.... BOOT_FOREACH(map_type::reference pair, my_map) { pair.first = 1;
How can this possibly work, being keys constant? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Sean Farrow wrote:
Hi:
Is it possible to use an std::pair with boost.foreach?
I’m getting all sorts of errors when trying to do this.
Any help appreciated.
Do you mean using a std::pair of iterators to designate the range? That should work. Or are you doing something like this: BOOST_FOREACH( std::pair<X,Y> x, a_map ) // OOPS The above won't work because the extra comma makes it look like you're trying to pass 3 arguments to the BOOST_FOREACH macro. Try this: typedef std::pair<X,Y> value_type; BOOST_FOREACH( value_type x, a_map ) HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (4)
-
Eric Niebler
-
Igor R
-
joaquin@tid.es
-
Sean Farrow