Boost logo

Boost :

Subject: Re: [boost] [UUID] version v12
From: Johannes Brunen (JBrunen_at_[hidden])
Date: 2008-10-13 07:12:02

Hello Andy,

after some investigations, I think that I have found the origin of the

In seed_rng.hpp the following code is used:

template <typename UniformRandomNumberGenerator>
inline void seed(UniformRandomNumberGenerator& rng)
    seed_rng seed_gen;
    boost::generator_iterator<seed_rng> begin(&seed_gen);
    boost::generator_iterator<seed_rng> end;
    rng.seed(begin, end);

Problematic is the construction of the end iterator. Looking into the code
(boost/generator_iterator.hpp) shows, that the default constructor of
generator_iterator does not initialize its member variables.

generator_iterator() {}

Howerver, the mersenne_twister seed code does compare the two given
iterators as shown below (boost/random/).

template<class It>
void seed(It& first, It last)
int j;
for(j = 0; j < n && first != last; ++j, ++first)
  x[j] = *first;
i = n;
if(first == last && j < n)
  throw std::invalid_argument("mersenne_twister::seed");

As the end iterator is not initialized the way is open for all throwing the
invalid_argument exception.

Locally, I did solve the problem by patching the default constructor of
class generator_iterator.

If this is a valid solution of the problem, it would be fine if anyone
applies the correction to the boost code.


Boost list run by bdawes at, gregod at, cpdaniel at, john at