Using boost::random as the RNG for std::random_shuffle

前端 未结 4 1979
一向
一向 2020-12-29 12:51

I have a program that uses the mt19937 random number generator from boost::random. I need to do a random_shuffle and want the random numbers generated for this to be from th

4条回答
  •  星月不相逢
    2020-12-29 13:14

    In C++03, you cannot instantiate a template based on a function-local type. If you move the rand class out of the function, it should work fine (disclaimer: not tested, there could be other sinister bugs).

    This requirement has been relaxed in C++0x, but I don't know whether the change has been implemented in GCC's C++0x mode yet, and I would be highly surprised to find it present in any other compiler.

提交回复
热议问题