1> ] 1> Q:\include\boost\1.39.0\boost/random/variate_generator.hpp(100) : see reference to function template instantiation 'unsigned short boost::uniform_int<IntType>::operator ()<boost::random::detail::pass_through_engine<UniformRandomNumberGenerator>>(Engine &)' being compiled 1> with 1> [ 1> IntType=boost::uint16_t, 1> UniformRandomNumberGenerator=boost::random::detail::pass_through_engine<boost::random::linear_congruential<boost::int32_t,48271,0,2147483647,399268537> , 1> Engine=boost::random::detail::pass_through_engine<boost::random::detail::pass_through_engine<boost::random::linear_congruential<boost::int32_t,48271,0,2147483647,399268537>
1> ] 1> Q:\include\boost\1.39.0\boost/random/variate_generator.hpp(100) : while compiling class template member function 'unsigned short boost::variate_generator<Engine,Distribution>::operator ()(void)' 1> with 1> [ 1> Engine=boost::minstd_rand &, 1> Distribution=boost::uniform_int<boost::uint16_t> 1> ] 1> c:\dev\agent\windows\tests\bit_search.hpp(54) : see reference to class template instantiation 'boost::variate_generator<Engine,Distribution>' being compiled 1> with 1> [ 1> Engine=boost::minstd_rand &, 1> Distribution=boost::uniform_int<boost::uint16_t> 1> ] 1> c:\dev\agent\windows\tests\bit_search.hpp(52) : while compiling class template member function 'boost::uint16_t rand_type_value<T>::generate(void)' 1> with 1> [ 1> T=boost::uint16_t 1> ] 1> c:\dev\agent\windows\tests\bit_search.hpp(62) : see reference to class template instantiation 'rand_type_value<T>' being compiled 1> with 1> [ 1> T=boost::uint16_t 1> ] 1>Q:\include\boost\1.39.0\boost/random/detail/signed_unsigned_tools.hpp(64) : warning C4244: 'return' : conversion from 'base_unsigned' to 'unsigned short', possible loss of data 1> Q:\include\boost\1.39.0\boost/random/detail/signed_unsigned_tools.hpp(64) : while compiling class template member function 'unsigned short boost::random::detail::add<T1,T2>::operator ()(T1,T2)' 1> with 1> [ 1> T1=base_unsigned, 1> T2=unsigned short 1> ] 1> Q:\include\boost\1.39.0\boost/random/uniform_int.hpp(116) : see reference to class template instantiation 'boost::random::detail::add<T1,T2>' being compiled 1> with 1> [ 1> T1=base_unsigned, 1> T2=unsigned short 1> ] 1> Q:\include\boost\1.39.0\boost/random/uniform_int.hpp(64) : see reference to function template instantiation 'unsigned short boost::uniform_int<IntType>::generate<Engine>(Engine &,unsigned short,unsigned short,unsigned short)' being compiled 1> with 1> [ 1> IntType=boost::uint16_t, 1> Engine=boost::random::detail::pass_through_engine<boost::random::detail::pass_through_engine<boost::random::linear_congruential<boost::int32_t,48271,0,2147483647,399268537>
1> ] 1>Q:\include\boost\1.39.0\boost/random/uniform_smallint.hpp(79) : warning C4244: 'return' : conversion from 'long' to 'unsigned short',
1> ] 1>Linking... 1>LINK : c:\dev\agent\windows\tests\debug-winxp\Win32\bin\tests.exe not found or not built by the last incremental link; performing full
I think I'm overlooking something very simple, but I'm trying to generate random numbers that are uniform over the open range of various data types. So I wrote this code: template<typename T> struct rand_type_range { typedef boost::numeric::bounds<T> bounds; static T generate() { static boost::uniform_int<T> range(bounds::lowest()+1, bounds::highest()-1); static boost::variate_generator<boost::minstd_rand&, boost::uniform_int<T> > generate(rng, range); return generate(); } }; Using this with anything other than a boost::uint32_t gives lots of warnings, although the results turn out correct. Looking at the warnings it seems the infrastructure is still trying to use boost::uint32_t's for everything, so am I missing something simple? 1>Q:\include\boost\1.39.0\boost/random/uniform_int.hpp(135) : warning C4244: '+=' : conversion from 'unsigned long' to 'unsigned short', possible loss of data 1> Q:\include\boost\1.39.0\boost/random/uniform_int.hpp(64) : see reference to function template instantiation 'unsigned short boost::uniform_int<IntType>::generate<Engine>(Engine &,unsigned short,unsigned short,unsigned short)' being compiled 1> with 1> [ 1> IntType=boost::uint16_t, 1> Engine=boost::random::detail::pass_through_engine<boost::random::detail::pass_through_engine<boost::random::linear_congruential<boost::int32_t,48271,0,2147483647,399268537> possible loss of data 1> Q:\include\boost\1.39.0\boost/random/uniform_int.hpp(150) : see reference to function template instantiation 'unsigned short boost::uniform_smallint<IntType>::operator ()<Engine>(Engine &)' being compiled 1> with 1> [ 1> IntType=unsigned short, 1> Engine=boost::random::detail::pass_through_engine<boost::random::detail::pass_through_engine<boost::random::linear_congruential<boost::int32_t,48271,0,2147483647,399268537> link
AMDG Zachary Turner wrote:
I think I'm overlooking something very simple, but I'm trying to generate random numbers that are uniform over the open range of various data types. So I wrote this code:
template<typename T> struct rand_type_range { typedef boost::numeric::bounds<T> bounds;
static T generate() { static boost::uniform_int<T> range(bounds::lowest()+1, bounds::highest()-1); static boost::variate_generator<boost::minstd_rand&, boost::uniform_int<T> > generate(rng, range);
return generate(); } };
Using this with anything other than a boost::uint32_t gives lots of warnings, although the results turn out correct. Looking at the warnings it seems the infrastructure is still trying to use boost::uint32_t's for everything, so am I missing something simple?
boost::uint32_t comes from boost::minstd_rand. I'll fix the warnings shortly. BTW, boost::uniform_int has a number of problems in 1.39, which have been fixed in the trunk. Given the way that you're using it, I think that the only problem you will see is that the distribution is not quite uniform. In Christ, Steven Watanabe
participants (2)
-
Steven Watanabe
-
Zachary Turner