Hi!
I cannot compile following code by g++ 4.3.2:
#include <stdlib.h> #include <algorithm> struct Generator { ptrdiff_t operator() (ptrdiff_t max) { return rand() % max; } }; // ... Generator generator; std::vector<size_t> indices; // fill vector std::random_shuffle(indices.begin(), indices.end(), generator); // error here!
Why my compiler throws following error in last line?
error: no matching function for call to ‘random_shuffle(__gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int, std::allocator<long unsigned int> > >, __gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int, std::allocator<long unsigned int> > >, Generator&)’
Thanks in advance!