jeudi 14 janvier 2016

Pass a==b as parameters to uniform_real_distribution ok

Is it ok to use std::uniform_real_distribution with a==b? This condition can be interpreted as no randomness.

In GNU c++ library:

explicit
param_type(_RealType __a = _RealType(0),
           _RealType __b = _RealType(1))
: _M_a(__a), _M_b(__b)
{
   _GLIBCXX_DEBUG_ASSERT(_M_a <= _M_b);
}

The assertion accepts a==b though it might require division by zero. Is this

  • An extension to the standard?
  • A clever design that works anyways?
  • An error that happens to work on certain CPUs?



Aucun commentaire:

Enregistrer un commentaire