Boost logo

Boost :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2007-05-12 20:45:50


Matthias Troyer wrote:

>
> On 11 May 2007, at 23:13, Neal Becker wrote:
>
>> diff -r 5fcada374f41 boost/random/uniform_real.hpp
>> --- a/boost/random/uniform_real.hpp Thu May 10 08:59:36 2007 -0400
>> +++ b/boost/random/uniform_real.hpp Fri May 11 11:12:44 2007 -0400
>> @@ -40,7 +40,7 @@ public:
>> #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
>> BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);
>> #endif
>> - assert(min_arg < max_arg);
>> + assert(min_arg <= max_arg);
>> }
>>
>> // compiler-generated copy ctor and assignment operator are fine
>
> This does not make sense to me. uniform_real should create numbers u
> that are
>
> min_arg <= u < maxarg
>
> Thus choosing minarg == maxarg does not make sense since the set of
> possible values would be empty.
>
It's a valid limiting case.

Here's the use case:

Your program has a random number generator. The range is set by command
line argument. For test purposes, you set the range to be infinitesimal.
As it is now, you get the assertion failure. There is no good reason for
this to fail, AFAICT. Allowing it is useful and harmless.


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