Boost logo

Boost Users :

Subject: Re: [Boost-users] bind: what am I doing wrong here?
From: Peter Dimov (pdimov_at_[hidden])
Date: 2009-04-14 19:54:45


Noah Roberts:

> // won't compile:
> std::transform(m.begin(), m.end(), keys.begin(),
> boost::bind(&std::pair<std::string,Test>::first, _1));

The value type of the map m is pair<string const, Test> - note the const.
Use the value_type typedef:

typedef std::map<std::string, Test> map_type;

std::transform( m.begin(), m.end(), keys.begin(),
    boost::bind(&map_type::value_type::first, _1) );

...
> 1> T=std::pair<std::string,Test>,
> 1> U=std::pair<const std::string,Test>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net