@@ -402,7 +402,7 @@ bool _Nrand_for_tr1(
402402}
403403
404404template <class _Gen, class = void>
405- struct _Has_static_min_max : false_type {};
405+ struct _Has_static_min_max : false_type {}; // TRANSITION, VSO-2417491: Should be a variable template
406406
407407// This checks a requirement of N4981 [rand.req.urng] `concept uniform_random_bit_generator` but doesn't attempt
408408// to implement the whole concept - we just need to distinguish Standard machinery from tr1 machinery.
@@ -461,8 +461,6 @@ _NODISCARD _Real _Nrand_impl(_Gen& _Gx) { // build a floating-point value from r
461461 }
462462}
463463
464- #define _NRAND(eng, resty) (_Nrand_impl<resty>(eng))
465-
466464_INLINE_VAR constexpr int _MP_len = 5;
467465using _MP_arr = uint64_t[_MP_len];
468466
@@ -2546,7 +2544,7 @@ public:
25462544private:
25472545 template <class _Engine>
25482546 result_type _Eval(_Engine& _Eng, const param_type& _Par0) const {
2549- return _NRAND (_Eng, double ) < _Par0._Px;
2547+ return _Nrand_impl<double> (_Eng) < _Par0._Px;
25502548 }
25512549
25522550 param_type _Par;
@@ -2713,7 +2711,7 @@ private:
27132711
27142712 _Ty1 _Val;
27152713 do {
2716- _Val = _CSTD log(_NRAND (_Eng, _Ty1 )) / _Par0._Log_1_p;
2714+ _Val = _CSTD log(_Nrand_impl<_Ty1> (_Eng)) / _Par0._Log_1_p;
27172715 } while (_Val >= _Ty1_max);
27182716 return static_cast<_Ty>(_Val);
27192717 }
@@ -2730,7 +2728,7 @@ public:
27302728 _NODISCARD _Ty operator()(_Engine& _Eng) const {
27312729 _Ty1 _Val = 1.0;
27322730 for (_Ty _Res = 0;; ++_Res) { // count repetitions
2733- _Val *= _NRAND (_Eng, _Ty1 );
2731+ _Val *= _Nrand_impl<_Ty1> (_Eng);
27342732 if (_Val <= _Gx0) {
27352733 return _Res;
27362734 }
@@ -2882,15 +2880,15 @@ private:
28822880 _Ty _Res;
28832881 _Ty1 _Yx;
28842882 for (;;) { // generate a tentative value
2885- _Yx = static_cast<_Ty1>(_CSTD tan(_Pi_val * _NRAND (_Eng, _Ty1 )));
2883+ _Yx = static_cast<_Ty1>(_CSTD tan(_Pi_val * _Nrand_impl<_Ty1> (_Eng)));
28862884 const _Ty1 _Mx{_Par0._Sqrt * _Yx + _Par0._Mean};
28872885 if (0.0 <= _Mx && _Mx < _Ty1_max) {
28882886 _Res = static_cast<_Ty>(_Mx);
28892887 break;
28902888 }
28912889 }
28922890
2893- if (_NRAND (_Eng, _Ty1 )
2891+ if (_Nrand_impl<_Ty1> (_Eng)
28942892 <= 0.9 * (1.0 + _Yx * _Yx) * _CSTD exp(_Res * _Par0._Logm - _XLgamma(_Res + 1.0) - _Par0._Gx1)) {
28952893 return _Res;
28962894 }
@@ -3050,15 +3048,15 @@ private:
30503048 if (_Par0._Tx < 25) { // generate directly
30513049 _Res = 0;
30523050 for (_Ty _Ix = 0; _Ix < _Par0._Tx; ++_Ix) {
3053- if (_NRAND (_Eng, _Ty1 ) < _Par0._Px) {
3051+ if (_Nrand_impl<_Ty1> (_Eng) < _Par0._Px) {
30543052 ++_Res;
30553053 }
30563054 }
30573055
30583056 return _Res;
30593057 } else if (_Par0._Mean < 1.0) {
30603058 // Events are rare, use waiting time method (Luc Devroye, Non-Uniform Random Variate Generation, p. 525).
3061- const _Ty1 _Rand = _NRAND (_Eng, _Ty1 );
3059+ const _Ty1 _Rand = _Nrand_impl<_Ty1> (_Eng);
30623060
30633061 // The exit condition is log(1 - _Rand)/t < log(1-p), which is equivalent to _Rand > 1 - (1-p)^t. If
30643062 // we have a cheap upper bound for 1-(1-p)^t, we can exit early without having to call log. We use two
@@ -3073,7 +3071,7 @@ private:
30733071 _Ty _Denom = _Par0._Tx;
30743072 _Ty1 _Sum = _CSTD log(_Ty1{1.0} - _Rand) / _Denom;
30753073 while (_Sum >= _Par0._Logp1 && --_Denom != 0) {
3076- _Sum += _CSTD log(_Ty1{1.0} - _NRAND (_Eng, _Ty1 )) / _Denom;
3074+ _Sum += _CSTD log(_Ty1{1.0} - _Nrand_impl<_Ty1> (_Eng)) / _Denom;
30773075 }
30783076 _Res = static_cast<_Ty>(_Par0._Tx - _Denom);
30793077 }
@@ -3084,14 +3082,14 @@ private:
30843082 for (;;) { // generate and reject
30853083 _Ty1 _Yx;
30863084 for (;;) { // generate a tentative value
3087- _Yx = static_cast<_Ty1>(_CSTD tan(_Pi_val * _NRAND (_Eng, _Ty1 )));
3085+ _Yx = static_cast<_Ty1>(_CSTD tan(_Pi_val * _Nrand_impl<_Ty1> (_Eng)));
30883086 const _Ty1 _Mx{_Par0._Sqrt * _Yx + _Par0._Mean};
30893087 if (0.0 <= _Mx && _Mx < _Ty1_Tx) {
30903088 _Res = static_cast<_Ty>(_Mx);
30913089 break;
30923090 }
30933091 }
3094- if (_NRAND (_Eng, _Ty1 )
3092+ if (_Nrand_impl<_Ty1> (_Eng)
30953093 <= 1.2 * _Par0._Sqrt * (1.0 + _Yx * _Yx)
30963094 * _CSTD exp(_Par0._Gx1 - _XLgamma(_Res + 1.0) - _XLgamma(_Par0._Tx - _Res + 1.0)
30973095 + _Res * _Par0._Logp + (_Par0._Tx - _Res) * _Par0._Logp1)) {
@@ -3226,7 +3224,7 @@ public:
32263224private:
32273225 template <class _Engine>
32283226 result_type _Eval(_Engine& _Eng, const param_type& _Par0) const {
3229- return _NRAND (_Eng, _Ty ) * (_Par0._Max - _Par0._Min) + _Par0._Min;
3227+ return _Nrand_impl<_Ty> (_Eng) * (_Par0._Max - _Par0._Min) + _Par0._Min;
32303228 }
32313229
32323230 param_type _Par;
@@ -3439,7 +3437,7 @@ public:
34393437private:
34403438 template <class _Engine>
34413439 result_type _Eval(_Engine& _Eng, const param_type& _Par0) const {
3442- return -_CSTD log(_Ty{1} - _NRAND (_Eng, _Ty )) / _Par0._Lambda;
3440+ return -_CSTD log(_Ty{1} - _Nrand_impl<_Ty> (_Eng)) / _Par0._Lambda;
34433441 }
34443442
34453443 param_type _Par;
@@ -3600,8 +3598,8 @@ private:
36003598 _Ty _Vx2;
36013599 _Ty _Sx;
36023600 for (;;) { // reject bad values to avoid generating NaN/Inf on the next calculations
3603- _Vx1 = 2 * _NRAND (_Eng, _Ty ) - 1;
3604- _Vx2 = 2 * _NRAND (_Eng, _Ty ) - 1;
3601+ _Vx1 = 2 * _Nrand_impl<_Ty> (_Eng) - 1;
3602+ _Vx2 = 2 * _Nrand_impl<_Ty> (_Eng) - 1;
36053603 _Sx = _Vx1 * _Vx1 + _Vx2 * _Vx2;
36063604 if (_Sx < _Ty{1} && _Vx1 != _Ty{0} && _Vx2 != _Ty{0}) {
36073605 // good values!
@@ -3779,9 +3777,9 @@ private:
37793777 if (_Par0._Alpha < 1) { // small values of alpha
37803778 // from Knuth
37813779 for (;;) { // generate and reject
3782- _Ux = _NRAND (_Eng, _Ty );
3780+ _Ux = _Nrand_impl<_Ty> (_Eng);
37833781 do {
3784- _Vx = _NRAND (_Eng, _Ty );
3782+ _Vx = _Nrand_impl<_Ty> (_Eng);
37853783 } while (_Vx == 0);
37863784
37873785 if (_Ux < _Par0._Px) { // small _Ux
@@ -3792,7 +3790,7 @@ private:
37923790 _Qx = _CSTD pow(_Xx, _Par0._Alpha - 1);
37933791 }
37943792
3795- if (_NRAND (_Eng, _Ty ) < _Qx) {
3793+ if (_Nrand_impl<_Ty> (_Eng) < _Qx) {
37963794 return _Par0._Beta * _Xx;
37973795 }
37983796 }
@@ -3804,10 +3802,10 @@ private:
38043802
38053803 if (_Par0._Alpha < 20.0 && (_Count = static_cast<int>(_Par0._Alpha)) == _Par0._Alpha) {
38063804 // _Alpha is small integer, compute directly
3807- _Yx = _NRAND (_Eng, _Ty );
3805+ _Yx = _Nrand_impl<_Ty> (_Eng);
38083806 while (--_Count) { // adjust result
38093807 do {
3810- _Ux = _NRAND (_Eng, _Ty );
3808+ _Ux = _Nrand_impl<_Ty> (_Eng);
38113809 } while (_Ux == 0);
38123810
38133811 _Yx *= _Ux;
@@ -3817,12 +3815,12 @@ private:
38173815
38183816 // no shortcuts
38193817 for (;;) { // generate and reject
3820- _Yx = static_cast<_Ty>(_CSTD tan(_Pi_val * _NRAND (_Eng, _Ty )));
3818+ _Yx = static_cast<_Ty>(_CSTD tan(_Pi_val * _Nrand_impl<_Ty> (_Eng)));
38213819 _Xx = _Par0._Sqrt * _Yx + _Par0._Alpha - 1;
38223820 if (0 < _Xx
3823- && _NRAND (_Eng, _Ty ) <= (1 + _Yx * _Yx)
3824- * _CSTD exp((_Par0._Alpha - 1) * _CSTD log(_Xx / (_Par0._Alpha - 1))
3825- - _Par0._Sqrt * _Yx)) {
3821+ && _Nrand_impl<_Ty> (_Eng) <= (1 + _Yx * _Yx)
3822+ * _CSTD exp((_Par0._Alpha - 1) * _CSTD log(_Xx / (_Par0._Alpha - 1))
3823+ - _Par0._Sqrt * _Yx)) {
38263824 return _Par0._Beta * _Xx;
38273825 }
38283826 }
@@ -3959,7 +3957,7 @@ public:
39593957private:
39603958 template <class _Engine>
39613959 result_type _Eval(_Engine& _Eng, const param_type& _Par0) const { // generate pseudo-random value
3962- _Ty _Px = (_Ty{1} - _NRAND (_Eng, _Ty ));
3960+ _Ty _Px = (_Ty{1} - _Nrand_impl<_Ty> (_Eng));
39633961 return _Par0._Bx * _CSTD pow(-_CSTD log(_Px), _Ty{1} / _Par0._Ax);
39643962 }
39653963
@@ -4093,7 +4091,7 @@ public:
40934091private:
40944092 template <class _Engine>
40954093 result_type _Eval(_Engine& _Eng, const param_type& _Par0) const { // generate pseudo-random value
4096- _Ty _Px = _NRAND (_Eng, _Ty );
4094+ _Ty _Px = _Nrand_impl<_Ty> (_Eng);
40974095 return _Par0._Ax - _Par0._Bx * _CSTD log(-_CSTD log(_Px));
40984096 }
40994097
@@ -4481,7 +4479,7 @@ public:
44814479private:
44824480 template <class _Engine>
44834481 result_type _Eval(_Engine& _Eng, const param_type& _Par0) const { // generate pseudo-random value
4484- _Ty Px = _NRAND (_Eng, _Ty );
4482+ _Ty Px = _Nrand_impl<_Ty> (_Eng);
44854483 return static_cast<_Ty>(_Par0._Ax + _Par0._Bx * _CSTD tan(_Pi_val * (Px - static_cast<_Ty>(0.5))));
44864484 }
44874485
@@ -4504,8 +4502,8 @@ public:
45044502 _Ty _Px1;
45054503 _Ty _Px2;
45064504 for (;;) { // reject large values
4507- _Px1 = _NRAND (_Eng, _Ty );
4508- _Px2 = _NRAND (_Eng, _Ty );
4505+ _Px1 = _Nrand_impl<_Ty> (_Eng);
4506+ _Px2 = _Nrand_impl<_Ty> (_Eng);
45094507 _Px1 = _CSTD pow(_Px1, _Ty{1} / _Ax);
45104508 _Px2 = _CSTD pow(_Px2, _Ty{1} / _Bx);
45114509 _Wx = _Px1 + _Px2;
@@ -5153,7 +5151,7 @@ public:
51535151private:
51545152 template <class _Engine>
51555153 result_type _Eval(_Engine& _Eng, const param_type& _Par0) const {
5156- double _Px = _NRAND (_Eng, double );
5154+ double _Px = _Nrand_impl<double> (_Eng);
51575155 const auto _First = _Par0._Pcdf.begin();
51585156 const auto _Position = _STD lower_bound(_First, _Prev_iter(_Par0._Pcdf.end()), _Px);
51595157 return static_cast<result_type>(_Position - _First);
@@ -5706,7 +5704,6 @@ _STL_RESTORE_DEPRECATED_WARNING
57065704#endif // _HAS_TR1_NAMESPACE
57075705_STD_END
57085706
5709- #undef _NRAND
57105707#undef _DISTRIBUTION_CONST
57115708
57125709// TRANSITION, GH-183
0 commit comments