summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/random.tcc
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-19 17:49:31 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-19 17:49:31 +0000
commit010799ab1f745b1e863d0b0d7457eec5d5b2512e (patch)
treea1a1417977e2e3064266363209e102fb113fa755 /libstdc++-v3/include/bits/random.tcc
parent985855e91178ec80e2cd83f81a0f100124d765ca (diff)
downloadgcc-010799ab1f745b1e863d0b0d7457eec5d5b2512e.tar.gz
2009-06-19 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/random.h (_Adaptor): Simplify for _DInputType always a floating point type. (uniform_int_distribution<>::uniform_int_distribution(_IntType, _IntType)): Fix second default argument. (uniform_int_distribution<>::_M_call): Remove. (uniform_int_distribution<>::operator()(_UniformRandomNumberGenerator&, const param_type&)): Only declare. * include/bits/random.tcc (uniform_int_distribution<>::_M_call( _UniformRandomNumberGenerator&, result_type, result_type, true_type): Remove. uniform_int_distribution<>::operator()(_UniformRandomNumberGenerator&, const param_type&): Define here. (geometric_distribution<>::operator()(_UniformRandomNumberGenerator&, const param_type&), discrete_distribution<>::operator() (_UniformRandomNumberGenerator&, const param_type&), piecewise_constant_distribution<>::operator() (_UniformRandomNumberGenerator&, const param_type&), piecewise_linear_distribution<>::operator() (_UniformRandomNumberGenerator&, const param_type&)): Use double as the second template argument of _Adaptor. * testsuite/26_numerics/random/uniform_int_distribution/cons/ default.cc: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148720 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/random.tcc')
-rw-r--r--libstdc++-v3/include/bits/random.tcc24
1 files changed, 12 insertions, 12 deletions
diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc
index 846b6b05711..87c46186b57 100644
--- a/libstdc++-v3/include/bits/random.tcc
+++ b/libstdc++-v3/include/bits/random.tcc
@@ -644,13 +644,13 @@ namespace std
template<typename _UniformRandomNumberGenerator>
typename uniform_int_distribution<_IntType>::result_type
uniform_int_distribution<_IntType>::
- _M_call(_UniformRandomNumberGenerator& __urng,
- result_type __min, result_type __max, true_type)
+ operator()(_UniformRandomNumberGenerator& __urng,
+ const param_type& __param)
{
// XXX Must be fixed to work well for *arbitrary* __urng.max(),
- // __urng.min(), __max, __min. Currently works fine only in the
- // most common case __urng.max() - __urng.min() >= __max - __min,
- // with __urng.max() > __urng.min() >= 0.
+ // __urng.min(), __param.b(), __param.a(). Currently works fine only
+ // in the most common case __urng.max() - __urng.min() >=
+ // __param.b() - __param.a(), with __urng.max() > __urng.min() >= 0.
typedef typename __gnu_cxx::__add_unsigned<typename
_UniformRandomNumberGenerator::result_type>::__type __urntype;
typedef typename __gnu_cxx::__add_unsigned<result_type>::__type
@@ -664,14 +664,14 @@ namespace std
const __urntype __urnmin = __urng.min();
const __urntype __urnmax = __urng.max();
const __urntype __urnrange = __urnmax - __urnmin;
- const __uctype __urange = __max - __min;
+ const __uctype __urange = __param.b() - __param.a();
const __uctype __udenom = (__urnrange <= __urange
? 1 : __urnrange / (__urange + 1));
do
__ret = (__urntype(__urng()) - __urnmin) / __udenom;
- while (__ret > __max - __min);
+ while (__ret > __param.b() - __param.a());
- return __ret + __min;
+ return __ret + __param.a();
}
template<typename _IntType, typename _CharT, typename _Traits>
@@ -799,7 +799,7 @@ namespace std
// The largest _RealType convertible to _IntType.
const double __thr =
std::numeric_limits<_IntType>::max() + __naf;
- __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
+ __detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
double __cand;
@@ -2021,7 +2021,7 @@ namespace std
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
- __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
+ __detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();
@@ -2193,7 +2193,7 @@ namespace std
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
- __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
+ __detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();
@@ -2383,7 +2383,7 @@ namespace std
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
- __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
+ __detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();