Standard Library Modules: Add compiler workarounds for `<random>` (#4906)

This commit is contained in:
Stephan T. Lavavej 2024-08-25 12:22:04 -07:00 коммит произвёл GitHub
Родитель 5f119276ac
Коммит 138e1161c9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -707,9 +707,9 @@ struct _Unsigned128 : _Base128 {
using _Signed_type = _Signed128;
using _Unsigned_type = _Unsigned128;
#if !_HAS_CXX17
#if !_HAS_CXX17 || (_HAS_CXX20 && !defined(__clang__) && !defined(__EDG__)) // TRANSITION, DevCom-10729775
constexpr _Unsigned128() noexcept : _Base128{} {}
#endif // !_HAS_CXX17
#endif // ^^^ workaround for C++20 MSVC modules and header units; should be guarded for !_HAS_CXX17 only ^^^
using _Base128::_Base128;
constexpr explicit _Unsigned128(const _Base128& _That) noexcept : _Base128{_That} {}
@ -1024,9 +1024,9 @@ struct _Signed128 : _Base128 {
using _Signed_type = _Signed128;
using _Unsigned_type = _Unsigned128;
#if !_HAS_CXX17
#if !_HAS_CXX17 || (_HAS_CXX20 && !defined(__clang__) && !defined(__EDG__)) // TRANSITION, DevCom-10729775
constexpr _Signed128() noexcept : _Base128{} {}
#endif // !_HAS_CXX17
#endif // ^^^ workaround for C++20 MSVC modules and header units; should be guarded for !_HAS_CXX17 only ^^^
using _Base128::_Base128;
constexpr explicit _Signed128(const _Base128& _That) noexcept : _Base128{_That} {}

Просмотреть файл

@ -593,6 +593,14 @@ void test_random() {
minstd_rand0 lcg;
lcg.discard(9999);
assert(lcg() == 1043618065); // N4868 [rand.predef]/1
#ifndef _MSVC_INTERNAL_TESTING // TRANSITION, VSO-2226569
// Test coverage for GH-4899 "Standard Library Modules: uniform_real_distribution emits
// error C2512: 'std::_Unsigned128': no appropriate default constructor available":
const double val = generate_canonical<double, 53>(lcg);
assert(val >= 0.0);
assert(val < 1.0);
#endif // ^^^ no workaround ^^^
}
void test_ranges() {