Boost logo

Boost Users :

From: David Walthall (walthall_at_[hidden])
Date: 2006-04-21 13:40:45


Hello,

I am using Visual Studio 7.1.3008. While using the Random library, I
ran into an issue with the seed function of mt19937. From what I can
gather, the compiler becomes confused about one of the overloads and
tries to call the seed function:
   template<class Generator>
   void seed(Generator & gen)

I couldn't this issue on the list of known issues for this compiler. Is
this known. For now, it appears that the work-around is to cast it as
an unsigned long.

Below is a small test file that demonstrates this issue.

Thank you,
David Walthall

////// boost_random_error.cpp //////
#include <boost/random/mersenne_twister.hpp>

int main()
{
     boost::mt19937 generator(42u);

     unsigned int uint = 42u;
     unsigned long int ulong = 42u;

     generator.seed(static_cast<unsigned int>(42u)); // ok
     generator.seed(42u); // ok
     generator.seed(static_cast<unsigned long>(uint)); // ok
     generator.seed(static_cast<unsigned int>(ulong)); // ok
     generator.seed(ulong); // ok

     // comment out the next lines to get it to compile
     generator.seed(static_cast<unsigned int>(uint)); // error
     generator.seed(uint); // error (also an error on g++ 3.4.4)

     return 0;
}
////// end of boost_random_error.cpp //////


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net