A
Alex Buell
Could anyone tell me why this program taken from the Thinking in C++
book won't compile with GCC 4.1.2? Here's the error:
C++ Binder.o
Binder.cpp: In function ‘int main()’:
Binder.cpp:19: error: no matching function for call to ‘copy
And here's the program itself:
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <iterator>
#include <vector>
#include "Generators.h"
using namespace std;
int main()
{
ostream_iterator<int> out(cout, " ");
vector<int> v(15);
srand(time(0));
generate(v.begin(), v.end(), URandGen(20));
copy(v.begin, v.end(), out);
transform(v.begin(), v.end(), v.begin(), bind2nd(multiplies<int>
(), 10)); copy(v.begin(), v.end(), out); }
The odd thing is that if I comment out the first copy() call, it
compiles just fine?
Thanks,
Alex
book won't compile with GCC 4.1.2? Here's the error:
C++ Binder.o
Binder.cpp: In function ‘int main()’:
Binder.cpp:19: error: no matching function for call to ‘copy
( said:&)’ /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g+
+-v4/bits/stl_algobase.h:376: note: candidates are: _OutputIterator
std::copy(_InputIterator, _InputIterator, _OutputIterator) [with
_InputIterator = __gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >, _OutputIterator =
std:stream_iterator<int, char, std::char_traits<char> >]
And here's the program itself:
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <iterator>
#include <vector>
#include "Generators.h"
using namespace std;
int main()
{
ostream_iterator<int> out(cout, " ");
vector<int> v(15);
srand(time(0));
generate(v.begin(), v.end(), URandGen(20));
copy(v.begin, v.end(), out);
transform(v.begin(), v.end(), v.begin(), bind2nd(multiplies<int>
(), 10)); copy(v.begin(), v.end(), out); }
The odd thing is that if I comment out the first copy() call, it
compiles just fine?
Thanks,
Alex