Boost logo

Boost :

From: Masaki Nomura (nomura_at_[hidden])
Date: 2004-11-05 01:08:11


Dear all:
Would anyone let me know the usage of the boost::uniform_int combined with
the one argument operator() of the variate_generator?
I'd like to change the maximum parameter of the distribution at every step.
#include <iostream>
#include <boost/random.hpp>
int
main( void ) {
  boost::variate_generator< boost::mt19937,
    boost::uniform_int< std::size_t > > gen( boost::mt19937( 3 ), boost::uniform_int< std::size_t >() );
  for ( std::size_t i(1); i < 100; ++i )
    std::cout << gen( i ) << std::endl;
  return 0;
}
The gcc aborted the compile with the following errors:
/usr/include/boost/random/variate_generator.hpp: In member function `typename
   Distribution::result_type boost::variate_generator<Engine,
   Distribution>::operator()(T) [with T = unsigned int, Engine =
   boost::mt19937, Distribution = boost::uniform_int<size_t>]':
uniform_int.cpp:9: instantiated from here
/usr/include/boost/random/variate_generator.hpp:107: error: no match for call
   to `(boost::uniform_int<size_t>) (
   boost::random::detail::pass_through_engine<boost::random::detail::pass_through_engine<boost::mt19937>
>&, unsigned int&)'

With regards,
Masaki Nomura


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk