Re: mapcar contest
Thanks for your help.
I wrote this small program as you suggested:
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
int main()
{
int data[] = {1, -2, 3, -4, 5, -6, 7};
std::vector<int> vi(data, data+sizeof(data)/sizeof(int));
std::list<int> li;
std::list<int>::iterator it(li.begin());
std::insert_iterator< std::list<int> > insert(li,it);
std::transform( vi.begin(), vi.end(), insert, abs );
return 0;
}
The compiler tells me:
/tmp $ g++ mapcar2.cpp
mapcar2.cpp: In function ?int main()?:
mapcar2.cpp:17: error: no matching function for call to
?transform(__gnu_cxx::__normal_iterator<int*, std::vector<int,
std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >,
std::insert_iterator<std::list<int, std::allocator<int> > >&,
<unresolved overloaded function type>)?
/tmp $
I am sorry but I can't decipher that. What is wrong?
Thanks in advance and excuse my ignorance.
jacob