Question

I'm here learning how to use boost::lambda. One question I have is about member function calling. It's just a test, and I'd like to do this with boost::lambda, as there are, obviously, half a million ways to copy the elements from one container to another container.

I have a list<int> which has 3 elements:

std::list<int> a;
a.push_back(2);
a.push_back(3);
a.push_back(4);

And a vector<int>:

vector<int> b;

I'm trying to do the following: for each element in a, push it back in b. Here's my shot:

std::for_each(a.begin(), a.end(), (b ->* (&std::vector<int>::push_back))(_1) );

The problem is that it's not accepting the member function call, telling:

no match for ‘operator->*’ in ‘b ->* &std::vector<int, std::allocator<int> >::push_back’

I tried some other ways, but they didn't work either.

Thanks in advance.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top