[Boost-bugs] [Boost C++ Libraries] #10921: Seeding boost::random::mt19937 from a pair of iterators throws an exception

Subject: [Boost-bugs] [Boost C++ Libraries] #10921: Seeding boost::random::mt19937 from a pair of iterators throws an exception
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-01-09 11:28:30


#10921: Seeding boost::random::mt19937 from a pair of iterators throws an exception
-------------------------------------------+---------------------------
 Reporter: Adam Romanek <romanek.adam@…> | Owner: no-maintainer
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: random
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
-------------------------------------------+---------------------------
 The problem is that when seeding `boost::random::mt19937` from a pair of
 iterators `std::invalid_argument("Not enough elements in call to seed")`
 exception is thrown.

 An isolated test case looks like this:
 {{{
 #include <boost/array.hpp>
 #include <boost/random.hpp>

 //typedef boost::random::rand48 generator_t;
 typedef boost::random::mt19937 generator_t;

 int main() {
   typedef boost::array<int, 3> seed_range_t;
   seed_range_t seed = {1, 2, 3};

   boost::random::seed_seq seed2(seed.begin(), seed.end());
   generator_t generator1(seed2); // works fine

   seed_range_t::iterator begin = seed.begin();
   generator_t generator2(begin, seed.end()); // throws
 std::invalid_argument("Not enough elements in call to seed")
 }
 }}}

 The documentation of the relevant constructor ![1] does not help too much.

 Please note that using the same input sequence through
 `boost::random::seed_seq` works fine. Moreover, the same input sequence
 passed directly to the constructor of `boost::random::rand48` generator
 also produces no exceptions.

 I'm not sure if `mersenne_twister_engine` needs larger input or the
 implementation is broken. Please advice.

 ![1]
 http://www.boost.org/doc/libs/1_57_0/doc/html/boost/random/mersenne_twister_engine.html#idp93974544-bb

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10921>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC