c++ - How do I pass standard generators to STL functions? -


#include <random> #include <algorithm> #include <vector>  int main() {     std::vector < int > = {1, 2, 3};     std::mt19937 generator;     std::random_shuffle(a.begin(), a.end(), generator); } 

i trying compile code g++ -std=c++0x, receiving huge compiler dump ending

/usr/include/c++/4.9.2/bits/random.h:546:7: note:   candidate expects 0 arguments, 1 provided 

any way of doing correctly?

the overload of std::random_shuffle you're trying use takes "randomfunc":

function object returning randomly chosen value of type convertible std::iterator_traits<randomit>::difference_type in interval [0,n) if invoked r(n)

in c++14, std::random_shuffle deprecated in favour of std::shuffle, takes generator rather "randomfunc". change function std::shuffle.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -