Skip to content

Commit f27eaed

Browse files
Merge pull request #1644 from StephanTLavavej/merge_spaceship
feature/spaceship: Merge toolset update
2 parents 5443c4a + 3c1da29 commit f27eaed

File tree

23 files changed

+706
-303
lines changed

23 files changed

+706
-303
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem
143143
The STL uses boost-math headers to provide P0226R1 Mathematical Special Functions. We recommend using [vcpkg][] to
144144
acquire this dependency.
145145

146-
1. Install Visual Studio 2019 16.9 Preview 3 or later.
146+
1. Install Visual Studio 2019 16.9 Preview 4 or later.
147147
* We recommend selecting "C++ CMake tools for Windows" in the VS Installer.
148148
This will ensure that you're using supported versions of CMake and Ninja.
149149
* Otherwise, install [CMake][] 3.19 or later, and [Ninja][] 1.10.2 or later.
@@ -158,7 +158,7 @@ acquire this dependency.
158158

159159
# How To Build With A Native Tools Command Prompt
160160

161-
1. Install Visual Studio 2019 16.9 Preview 3 or later.
161+
1. Install Visual Studio 2019 16.9 Preview 4 or later.
162162
* We recommend selecting "C++ CMake tools for Windows" in the VS Installer.
163163
This will ensure that you're using supported versions of CMake and Ninja.
164164
* Otherwise, install [CMake][] 3.19 or later, and [Ninja][] 1.10.2 or later.

azure-pipelines.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ variables:
88
buildOutputLocation: 'D:\build'
99
vcpkgLocation: '$(Build.SourcesDirectory)/vcpkg'
1010

11-
pool: 'StlBuild-2021-01-20-2'
11+
pool: 'StlBuild-2021-02-09'
1212

1313
stages:
1414
- stage: Code_Format
@@ -69,7 +69,7 @@ stages:
6969
vsDevCmdArch: x86
7070

7171
- stage: Build_And_Test_x64
72-
dependsOn: Code_Format
72+
dependsOn: Build_And_Test_x86
7373
displayName: 'Build and Test'
7474
jobs:
7575
- template: azure-devops/native-build-test.yml
@@ -78,7 +78,7 @@ stages:
7878
vsDevCmdArch: amd64
7979

8080
- stage: Build_ARM
81-
dependsOn: Code_Format
81+
dependsOn: Build_And_Test_x86
8282
displayName: 'Build'
8383
jobs:
8484
- template: azure-devops/cross-build.yml
@@ -87,7 +87,7 @@ stages:
8787
vsDevCmdArch: arm
8888

8989
- stage: Build_ARM64
90-
dependsOn: Code_Format
90+
dependsOn: Build_And_Test_x86
9191
displayName: 'Build'
9292
jobs:
9393
- template: azure-devops/cross-build.yml

stl/inc/charconv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ _NODISCARD to_chars_result _Integer_to_chars(
127127
} while (_Value != 0);
128128
break;
129129

130+
case 3:
131+
case 5:
132+
case 6:
133+
case 7:
134+
case 9:
135+
do {
136+
*--_RNext = static_cast<char>('0' + _Value % _Base);
137+
_Value = static_cast<_Unsigned>(_Value / _Base);
138+
} while (_Value != 0);
139+
break;
140+
130141
default:
131142
do {
132143
*--_RNext = _Charconv_digits[_Value % _Base];

stl/inc/chrono

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,35 +1394,31 @@ namespace chrono {
13941394
// courtesy of Howard Hinnant
13951395
// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
13961396
_NODISCARD static constexpr year_month_day _Civil_from_days(int _Tp) noexcept {
1397-
static_assert(numeric_limits<unsigned int>::digits >= 18);
1398-
static_assert(numeric_limits<int>::digits >= 20);
1399-
const int _Zx = _Tp + 719468; // Shift epoch to 0000-03-01
1400-
const int _Era = (_Zx >= 0 ? _Zx : _Zx - 146096) / 146097;
1401-
const unsigned int _Day_of_era = static_cast<unsigned int>(_Zx - _Era * 146097); // [0, 146096]
1402-
const unsigned int _Year_of_era =
1403-
(_Day_of_era - _Day_of_era / 1460 + _Day_of_era / 36524 - _Day_of_era / 146096) / 365; // [0, 399]
1404-
const int _Year = static_cast<int>(_Year_of_era) + _Era * 400; // Where March is the first month
1405-
const unsigned int _Day_of_year =
1406-
_Day_of_era - (365 * _Year_of_era + _Year_of_era / 4 - _Year_of_era / 100); // [0, 365]
1407-
const unsigned int _Mp = (5 * _Day_of_year + 2) / 153; // [0, 11]
1408-
const unsigned int _Day = _Day_of_year - (153 * _Mp + 2) / 5 + 1; // [1, 31]
1409-
const unsigned int _Month = _Mp + (_Mp < 10 ? 3 : static_cast<unsigned int>(-9)); // [1, 12]
1397+
static_assert(numeric_limits<unsigned int>::digits >= 32);
1398+
static_assert(numeric_limits<int>::digits >= 26);
1399+
const int _Zx = _Tp + 719468; // Shift epoch to 0000-03-01
1400+
const int _Century = (_Zx >= 0 ? 4 * _Zx + 3 : 4 * _Zx - 146093) / 146097;
1401+
const unsigned int _Day_of_century =
1402+
static_cast<unsigned int>(_Zx - ((146097 * _Century) >> 2)); // [0, 36524]
1403+
const unsigned int _Year_of_century = (91867 * (_Day_of_century + 1)) >> 25; // [0, 99]
1404+
const int _Year = static_cast<int>(_Year_of_century) + _Century * 100; // Where March is the first month
1405+
const unsigned int _Day_of_year = _Day_of_century - ((1461 * _Year_of_century) >> 2); // [0, 365]
1406+
const unsigned int _Mp = (535 * _Day_of_year + 333) >> 14; // [0, 11]
1407+
const unsigned int _Day = _Day_of_year - ((979 * _Mp + 19) >> 5) + 1; // [1, 31]
1408+
const unsigned int _Month = _Mp + (_Mp < 10 ? 3 : static_cast<unsigned int>(-9)); // [1, 12]
14101409
return year_month_day{_CHRONO year{_Year + (_Month <= 2)}, _CHRONO month{_Month}, _CHRONO day{_Day}};
14111410
}
14121411
// courtesy of Howard Hinnant
14131412
// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
14141413
_NODISCARD constexpr days _Days_from_civil() const noexcept {
14151414
static_assert(numeric_limits<unsigned int>::digits >= 18);
1416-
static_assert(numeric_limits<int>::digits >= 20);
1417-
const int _Ye = static_cast<int>(_Year) - (_Month <= _CHRONO month{2});
1418-
const unsigned int _Mo = static_cast<unsigned int>(_Month);
1419-
const int _Era = (_Ye >= 0 ? _Ye : _Ye - 399) / 400;
1420-
const unsigned int _Year_of_era = static_cast<unsigned int>(_Ye - _Era * 400); // [0, 399]
1421-
const unsigned int _Day_of_year = (153 * (_Mo + (_Mo > 2 ? static_cast<unsigned int>(-3) : 9)) + 2) / 5
1422-
+ static_cast<unsigned int>(_Day) - 1; // [0, 365]
1423-
const unsigned int _Day_of_era =
1424-
_Year_of_era * 365 + _Year_of_era / 4 - _Year_of_era / 100 + _Day_of_year; // [0, 146096]
1425-
return days{_Era * 146097 + static_cast<int>(_Day_of_era) - 719468};
1415+
static_assert(numeric_limits<int>::digits >= 26);
1416+
const unsigned int _Mo = static_cast<unsigned int>(_Month); // [1, 12]
1417+
const int _Ye = static_cast<int>(_Year) - (_Mo <= 2);
1418+
const int _Century = (_Ye >= 0 ? _Ye : _Ye - 99) / 100;
1419+
const unsigned int _Mp = _Mo + (_Mo > 2 ? static_cast<unsigned int>(-3) : 9); // [0, 11]
1420+
const int _Day_of_year = static_cast<int>(((979 * _Mp + 19) >> 5) + static_cast<unsigned int>(_Day)) - 1;
1421+
return days{((_Ye * 1461) >> 2) - _Century + (_Century >> 2) + _Day_of_year - 719468};
14261422
}
14271423
};
14281424

stl/inc/random

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2428,7 +2428,7 @@ public:
24282428
_Ty1 _Logp;
24292429
_Ty1 _Logp1;
24302430

2431-
_Small_poisson_distribution<_Ty> _Small;
2431+
_Small_poisson_distribution<_Ty> _Small; // TRANSITION, ABI: unused
24322432
};
24332433

24342434
binomial_distribution() : _Par(1, _Ty1(0.5)) {}
@@ -2505,8 +2505,26 @@ private:
25052505

25062506
return _Res;
25072507
} else if (_Par0._Mean < 1.0) {
2508-
// events are rare, use Poisson distribution
2509-
_Res = _Par0._Small(_Eng);
2508+
// Events are rare, use waiting time method (Luc Devroye, Non-Uniform Random Variate Generation, p. 525).
2509+
const _Ty1 _Rand = _NRAND(_Eng, _Ty1);
2510+
2511+
// The exit condition is log(1 - _Rand)/t < log(1-p), which is equivalent to _Rand > 1 - (1-p)^t. If
2512+
// we have a cheap upper bound for 1-(1-p)^t, we can exit early without having to call log. We use two
2513+
// such bounds, one that is tight for mean ~0 and another for mean ~1. In the first case, Bernoulli's
2514+
// inequality gives -1+p*t >= -(1-p)^t, so 1 - (1-p)^t <= p*t = mean. For the other bound, 1-(1-p)^t =
2515+
// 1-(1-p)(1-mean/t)^(t-1) <= 1-(1-p)(1-1/t)^(t-1) <= 1-(1-p)/e.
2516+
const _Ty1 _Ub =
2517+
(_STD min)(_Par0._Mean, _Ty1{3.678794411714423216e-1} * _Par0._Pp + _Ty1{6.32120558828557678e-1});
2518+
if (_Rand > _Ub) {
2519+
_Res = _Ty{0};
2520+
} else {
2521+
_Ty _Denom = _Par0._Tx;
2522+
_Ty1 _Sum = _CSTD log(_Ty1{1.0} - _Rand) / _Denom;
2523+
while (_Sum >= _Par0._Logp1 && --_Denom != 0) {
2524+
_Sum += _CSTD log(_Ty1{1.0} - _NRAND(_Eng, _Ty1)) / _Denom;
2525+
}
2526+
_Res = static_cast<_Ty>(_Par0._Tx - _Denom);
2527+
}
25102528
} else { // no shortcuts
25112529
using _Uty = make_unsigned_t<_Ty>;
25122530
const auto _Ty1_Tx{_Float_upper_bound<_Ty1>(static_cast<_Uty>(_Par0._Tx))};
@@ -2780,7 +2798,7 @@ public:
27802798
}
27812799

27822800
_NODISCARD result_type(max)() const { // get largest possible result
2783-
return (numeric_limits<result_type>::max)();
2801+
return numeric_limits<result_type>::infinity();
27842802
}
27852803

27862804
void reset() {} // clear internal state
@@ -2917,11 +2935,11 @@ public:
29172935
}
29182936

29192937
_NODISCARD result_type(min)() const { // get smallest possible result
2920-
return numeric_limits<result_type>::denorm_min();
2938+
return -numeric_limits<result_type>::infinity();
29212939
}
29222940

29232941
_NODISCARD result_type(max)() const { // get largest possible result
2924-
return (numeric_limits<result_type>::max)();
2942+
return numeric_limits<result_type>::infinity();
29252943
}
29262944

29272945
void reset() { // clear internal state
@@ -3057,7 +3075,7 @@ public:
30573075
}
30583076

30593077
_NODISCARD bool operator==(const param_type& _Right) const {
3060-
return _Px == _Right._Px;
3078+
return _Alpha == _Right._Alpha && _Beta == _Right._Beta;
30613079
}
30623080

30633081
_NODISCARD bool operator!=(const param_type& _Right) const {
@@ -3111,11 +3129,11 @@ public:
31113129
}
31123130

31133131
_NODISCARD result_type(min)() const { // get smallest possible result
3114-
return numeric_limits<result_type>::denorm_min();
3132+
return result_type{0.0};
31153133
}
31163134

31173135
_NODISCARD result_type(max)() const { // get largest possible result
3118-
return (numeric_limits<result_type>::max)();
3136+
return numeric_limits<result_type>::infinity();
31193137
}
31203138

31213139
void reset() {} // clear internal state
@@ -3306,7 +3324,7 @@ public:
33063324
}
33073325

33083326
_NODISCARD result_type(max)() const { // get largest possible result
3309-
return (numeric_limits<result_type>::max)();
3327+
return numeric_limits<result_type>::infinity();
33103328
}
33113329

33123330
void reset() {} // clear internal state
@@ -3438,11 +3456,11 @@ public:
34383456
}
34393457

34403458
_NODISCARD result_type(min)() const { // get smallest possible result
3441-
return (numeric_limits<result_type>::min)();
3459+
return -numeric_limits<result_type>::infinity();
34423460
}
34433461

34443462
_NODISCARD result_type(max)() const { // get largest possible result
3445-
return (numeric_limits<result_type>::max)();
3463+
return numeric_limits<result_type>::infinity();
34463464
}
34473465

34483466
void reset() {} // clear internal state
@@ -3576,11 +3594,11 @@ public:
35763594
}
35773595

35783596
_NODISCARD result_type(min)() const { // get smallest possible result
3579-
return -(numeric_limits<result_type>::max)();
3597+
return result_type{0.0};
35803598
}
35813599

35823600
_NODISCARD result_type(max)() const { // get largest possible result
3583-
return (numeric_limits<result_type>::max)();
3601+
return numeric_limits<result_type>::infinity();
35843602
}
35853603

35863604
void reset() {} // clear internal state
@@ -3702,11 +3720,11 @@ public:
37023720
}
37033721

37043722
_NODISCARD result_type(min)() const { // get smallest possible result
3705-
return numeric_limits<result_type>::denorm_min();
3723+
return result_type{0.0};
37063724
}
37073725

37083726
_NODISCARD result_type(max)() const { // get largest possible result
3709-
return (numeric_limits<result_type>::max)();
3727+
return numeric_limits<result_type>::infinity();
37103728
}
37113729

37123730
void reset() {} // clear internal state
@@ -3834,11 +3852,11 @@ public:
38343852
}
38353853

38363854
_NODISCARD result_type(min)() const { // get smallest possible result
3837-
return -(numeric_limits<result_type>::max)();
3855+
return -numeric_limits<result_type>::infinity();
38383856
}
38393857

38403858
_NODISCARD result_type(max)() const { // get largest possible result
3841-
return (numeric_limits<result_type>::max)();
3859+
return numeric_limits<result_type>::infinity();
38423860
}
38433861

38443862
void reset() {} // clear internal state
@@ -4035,7 +4053,7 @@ public:
40354053
}
40364054

40374055
_NODISCARD result_type(max)() const { // get largest possible result
4038-
return (numeric_limits<result_type>::max)();
4056+
return numeric_limits<result_type>::infinity();
40394057
}
40404058

40414059
void reset() {} // clear internal state
@@ -4168,11 +4186,11 @@ public:
41684186
}
41694187

41704188
_NODISCARD result_type(min)() const { // get smallest possible result
4171-
return -(numeric_limits<result_type>::max)();
4189+
return -numeric_limits<result_type>::infinity();
41724190
}
41734191

41744192
_NODISCARD result_type(max)() const { // get largest possible result
4175-
return (numeric_limits<result_type>::max)();
4193+
return numeric_limits<result_type>::infinity();
41764194
}
41774195

41784196
void reset() {} // clear internal state

stl/inc/regex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2749,7 +2749,7 @@ public:
27492749
_MyRe = nullptr;
27502750

27512751
#if _ITERATOR_DEBUG_LEVEL == 2
2752-
this->_Orphan_me();
2752+
this->_Orphan_me_v2();
27532753
#endif // _ITERATOR_DEBUG_LEVEL
27542754

27552755
return *this;

stl/inc/xhash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,7 @@ protected:
18411841
}
18421842
}
18431843

1844+
template <bool _Multi2 = _Traits::_Multi, enable_if_t<_Multi2, int> = 0>
18441845
_NODISCARD bool _Multi_equal(const _Hash& _Right) const {
18451846
static_assert(_Traits::_Multi, "This function only works with multi containers");
18461847
_STL_INTERNAL_CHECK(this->size() == _Right.size());

0 commit comments

Comments
 (0)