I'm trying to use this vector.h function:
random_shuffle(s.begin()+from+i,s.begin()+to,s);
This error happens:
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_algo.h|5255|error: no match for call to '(std::vector<int>) (__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'|
Any idea? Thank in advance!
The third parameter to std::random_shuffle
(assuming you are talking about that, if not, please clarify your question) must be a
function object returning a randomly chosen value of type convertible to
std::iterator_traits<RandomIt>::difference_type
in the interval[0,n)
if invoked asr(n)
(from here ), not a vector. You probably meant to use the two argument variant of the function:
random_shuffle(s.begin()+from+i,s.begin()+to);
Also, please note that std::random_shuffle
is obsolete. You should be using std::shuffle
instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.