diff --git a/stl/inc/random b/stl/inc/random index 5c87135054d..d31d5fb7a2f 100644 --- a/stl/inc/random +++ b/stl/inc/random @@ -790,12 +790,6 @@ protected: typename _Swc_Traits::_Cy_t _Carry; }; -template -const size_t _Swc_base<_Ty, _Sx, _Rx, _Swc_Traits>::short_lag; - -template -const size_t _Swc_base<_Ty, _Sx, _Rx, _Swc_Traits>::long_lag; - template struct _Swc_traits { // traits for subtract_with_carry generator using _Cy_t = int; @@ -1005,6 +999,18 @@ public: }; #if _HAS_TR1_NAMESPACE +_CONSTEVAL double _Cx_exp2(const int _Exp) noexcept { + double _Ret = 1.0; + for (int _Count = _Exp; _Count > 0; --_Count) { + _Ret *= 2.0; + } + for (int _Count = _Exp; _Count < 0; ++_Count) { + _Ret *= 0.5; + } + + return _Ret; +} + template struct _Swc_01_traits { // traits for subtract_with_carry_01 generator using _Cy_t = _Ty; @@ -1012,9 +1018,9 @@ struct _Swc_01_traits { // traits for subtract_with_carry_01 generator using _Mod_t = _Ty; using _Seed_t = unsigned int; - static const _Cy_t _Cy; - static const _Mod_t _Mod; - static const _Ty _Max; + static constexpr _Cy_t _Cy = static_cast<_Cy_t>(_Cx_exp2(static_cast(-static_cast(_Wx)))); + static constexpr _Mod_t _Mod = 1; + static constexpr _Ty _Max = 1; static constexpr int _Nwords = (_Wx + 31) / 32; template @@ -1058,24 +1064,10 @@ struct _Swc_01_traits { // traits for subtract_with_carry_01 generator } private: - static const _Ty _Scale1; + static constexpr _Ty _Scale1 = static_cast<_Ty>(_Cx_exp2(_Wx % 32)); static constexpr unsigned long _Mask = ~((~0UL) << (_Wx % 32)); }; -template -const typename _Swc_01_traits<_Ty, _Wx, _Rx>::_Cy_t - _Swc_01_traits<_Ty, _Wx, _Rx>::_Cy = static_cast::_Cy_t>( - _CSTD ldexp(1.0, static_cast(-static_cast(_Wx)))); - -template -const typename _Swc_01_traits<_Ty, _Wx, _Rx>::_Mod_t _Swc_01_traits<_Ty, _Wx, _Rx>::_Mod = 1; - -template -const _Ty _Swc_01_traits<_Ty, _Wx, _Rx>::_Max = 1; - -template -const _Ty _Swc_01_traits<_Ty, _Wx, _Rx>::_Scale1 = static_cast<_Ty>(_CSTD ldexp(1.0, _Wx % 32)); - template class _DEPRECATE_TR1_NAMESPACE subtract_with_carry_01 : public _Swc_base<_Ty, _Sx, _Rx, _Swc_01_traits<_Ty, _Wx, _Rx>> { // subtract_with_carry_01 generator @@ -1091,12 +1083,6 @@ public: template = 0> subtract_with_carry_01(_Gen& _Gx) : _Mybase(_Gx) {} }; - -_STL_DISABLE_DEPRECATED_WARNING -template -const size_t subtract_with_carry_01<_Ty, _Wx, _Sx, _Rx>::word_size; -_STL_RESTORE_DEPRECATED_WARNING - #endif // _HAS_TR1_NAMESPACE template @@ -1443,12 +1429,6 @@ private: int _Nx; }; -template -const int discard_block<_Engine, _Px, _Rx>::block_size; - -template -const int discard_block<_Engine, _Px, _Rx>::used_block; - template class discard_block_engine : public discard_block<_Engine, _Px, _Rx> { // discard_block_engine compound engine public: