Re: C++0X uniform_int_distribution and uniform_real_distribution
jkherciueh@gmx.net wrote:
Andrei Alexandrescu (See Website For Email wrote:
It's all a simple matter of expected interface. All I do is look up an
algorithm that entails choosing a random number in [a, b], and then code
it in C++. Then I'd naturally want to generate random numbers in [a, b]
and not [a, b), without caring about how often b will occur, or whether
it will occur at all in any given run.
Again, I'm getting back to the same theme: I don't want to become an
expert in random numbers in order to get one. In this particular
instance, I don't want to have to sit down with pen and paper and
convince myself that [a, b) will do for me when I want to encode [a, b].
Whatever task I'm up to mentions [a, b]. Then I should call a function
that yields just that.
I guess, one way to integrate that with the current framework, would be to
have a constructor
unform_real_distribution ( RealType a = 0.0 , RealType b = 1.0,
bool includes_left = true,
bool includes_right = false )
I think that would be great. Another Idea I had was:
template <class some_fp, char left_limit = '[', char right_limit = ')'>
class uniform_real_distribution { ... };
It's quite self-explanatory :o).
Andrei
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]