On 8/23/06, Minkoo Seo wrote:
for_each(m.begin(), m.end(),
bind(&map::insert, &m2,
bind(&make_pair,
bind(&map::value_type::first, _1),
bind(&map::value_type::second, _1))));
Unfortunately, the above code fails to compile and I have no idea
why it fails. I'm using g++ and the errors are as follows:
First off, just thought I would mention that for an example such as this,
regular boost::bind would probably suffice. You don't need lambda.
Second of all, I don't know which insert function you are trying to call,
but you should be able to write this code instead, which is much simpler:
for_each(m.begin(), m.end(),
bind(&map::insert, m2, _1));
Finally, even that fails to compile! I believe the problem is that since
insert is an overloaded function, boost cannot figure out which one to
call. So you help it out by type-casting explicitly, like this:
typedef pair