I am trying to use Boost :: bind and std :: copy to print the values ββin a list of lists. Obviously, I could use loops, and I can do this for clarity, but I would still like to know what I'm doing wrong here.
Here is a distilled version of my code:
#include <boost/bind.hpp>
#include <iterator>
#include <algorithm>
#include <list>
#include <iostream>
using namespace std;
using namespace boost;
int main(int argc, char **argv){
list<int> a;
a.push_back(1);
list< list<int> > a_list;
a_list.push_back(a);
ostream_iterator<int> int_output(cout,"\n");
for_each(a_list.begin(),a_list.end(),
bind(copy,
bind<list<int>::iterator>(&list<int>::begin,_1),
bind<list<int>::iterator>(&list<int>::end,_1),
ref(int_output)
)
);
return 0;
}
Compiler error
error: no matching function call to bind(<unresolved overloaded function type> .....
I think this means that bind cannot figure out what type of return for external binding should be. I do not blame it because I canβt. Any ideas?
source
share