Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem
The STL uses boost-math headers to provide P0226R1 Mathematical Special Functions. We recommend using [vcpkg][] to
acquire this dependency.

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

# How To Build With A Native Tools Command Prompt

1. Install Visual Studio 2019 16.9 Preview 3 or later.
1. Install Visual Studio 2019 16.9 Preview 4 or later.
* We recommend selecting "C++ CMake tools for Windows" in the VS Installer.
This will ensure that you're using supported versions of CMake and Ninja.
* Otherwise, install [CMake][] 3.19 or later, and [Ninja][] 1.10.2 or later.
Expand Down
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variables:
buildOutputLocation: 'D:\build'
vcpkgLocation: '$(Build.SourcesDirectory)/vcpkg'

pool: 'StlBuild-2021-01-20-2'
pool: 'StlBuild-2021-02-09'

stages:
- stage: Code_Format
Expand Down Expand Up @@ -69,7 +69,7 @@ stages:
vsDevCmdArch: x86

- stage: Build_And_Test_x64
dependsOn: Code_Format
dependsOn: Build_And_Test_x86
displayName: 'Build and Test'
jobs:
- template: azure-devops/native-build-test.yml
Expand All @@ -78,7 +78,7 @@ stages:
vsDevCmdArch: amd64

- stage: Build_ARM
dependsOn: Code_Format
dependsOn: Build_And_Test_x86
displayName: 'Build'
jobs:
- template: azure-devops/cross-build.yml
Expand All @@ -87,7 +87,7 @@ stages:
vsDevCmdArch: arm

- stage: Build_ARM64
dependsOn: Code_Format
dependsOn: Build_And_Test_x86
displayName: 'Build'
jobs:
- template: azure-devops/cross-build.yml
Expand Down
11 changes: 11 additions & 0 deletions stl/inc/charconv
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ _NODISCARD to_chars_result _Integer_to_chars(
} while (_Value != 0);
break;

case 3:
case 5:
case 6:
case 7:
case 9:
do {
*--_RNext = static_cast<char>('0' + _Value % _Base);
_Value = static_cast<_Unsigned>(_Value / _Base);
} while (_Value != 0);
break;

default:
do {
*--_RNext = _Charconv_digits[_Value % _Base];
Expand Down
42 changes: 19 additions & 23 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -1394,35 +1394,31 @@ namespace chrono {
// courtesy of Howard Hinnant
// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
_NODISCARD static constexpr year_month_day _Civil_from_days(int _Tp) noexcept {
static_assert(numeric_limits<unsigned int>::digits >= 18);
static_assert(numeric_limits<int>::digits >= 20);
const int _Zx = _Tp + 719468; // Shift epoch to 0000-03-01
const int _Era = (_Zx >= 0 ? _Zx : _Zx - 146096) / 146097;
const unsigned int _Day_of_era = static_cast<unsigned int>(_Zx - _Era * 146097); // [0, 146096]
const unsigned int _Year_of_era =
(_Day_of_era - _Day_of_era / 1460 + _Day_of_era / 36524 - _Day_of_era / 146096) / 365; // [0, 399]
const int _Year = static_cast<int>(_Year_of_era) + _Era * 400; // Where March is the first month
const unsigned int _Day_of_year =
_Day_of_era - (365 * _Year_of_era + _Year_of_era / 4 - _Year_of_era / 100); // [0, 365]
const unsigned int _Mp = (5 * _Day_of_year + 2) / 153; // [0, 11]
const unsigned int _Day = _Day_of_year - (153 * _Mp + 2) / 5 + 1; // [1, 31]
const unsigned int _Month = _Mp + (_Mp < 10 ? 3 : static_cast<unsigned int>(-9)); // [1, 12]
static_assert(numeric_limits<unsigned int>::digits >= 32);
static_assert(numeric_limits<int>::digits >= 26);
const int _Zx = _Tp + 719468; // Shift epoch to 0000-03-01
const int _Century = (_Zx >= 0 ? 4 * _Zx + 3 : 4 * _Zx - 146093) / 146097;
const unsigned int _Day_of_century =
static_cast<unsigned int>(_Zx - ((146097 * _Century) >> 2)); // [0, 36524]
const unsigned int _Year_of_century = (91867 * (_Day_of_century + 1)) >> 25; // [0, 99]
const int _Year = static_cast<int>(_Year_of_century) + _Century * 100; // Where March is the first month
const unsigned int _Day_of_year = _Day_of_century - ((1461 * _Year_of_century) >> 2); // [0, 365]
const unsigned int _Mp = (535 * _Day_of_year + 333) >> 14; // [0, 11]
const unsigned int _Day = _Day_of_year - ((979 * _Mp + 19) >> 5) + 1; // [1, 31]
const unsigned int _Month = _Mp + (_Mp < 10 ? 3 : static_cast<unsigned int>(-9)); // [1, 12]
return year_month_day{_CHRONO year{_Year + (_Month <= 2)}, _CHRONO month{_Month}, _CHRONO day{_Day}};
}
// courtesy of Howard Hinnant
// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
_NODISCARD constexpr days _Days_from_civil() const noexcept {
static_assert(numeric_limits<unsigned int>::digits >= 18);
static_assert(numeric_limits<int>::digits >= 20);
const int _Ye = static_cast<int>(_Year) - (_Month <= _CHRONO month{2});
const unsigned int _Mo = static_cast<unsigned int>(_Month);
const int _Era = (_Ye >= 0 ? _Ye : _Ye - 399) / 400;
const unsigned int _Year_of_era = static_cast<unsigned int>(_Ye - _Era * 400); // [0, 399]
const unsigned int _Day_of_year = (153 * (_Mo + (_Mo > 2 ? static_cast<unsigned int>(-3) : 9)) + 2) / 5
+ static_cast<unsigned int>(_Day) - 1; // [0, 365]
const unsigned int _Day_of_era =
_Year_of_era * 365 + _Year_of_era / 4 - _Year_of_era / 100 + _Day_of_year; // [0, 146096]
return days{_Era * 146097 + static_cast<int>(_Day_of_era) - 719468};
static_assert(numeric_limits<int>::digits >= 26);
const unsigned int _Mo = static_cast<unsigned int>(_Month); // [1, 12]
const int _Ye = static_cast<int>(_Year) - (_Mo <= 2);
const int _Century = (_Ye >= 0 ? _Ye : _Ye - 99) / 100;
const unsigned int _Mp = _Mo + (_Mo > 2 ? static_cast<unsigned int>(-3) : 9); // [0, 11]
const int _Day_of_year = static_cast<int>(((979 * _Mp + 19) >> 5) + static_cast<unsigned int>(_Day)) - 1;
return days{((_Ye * 1461) >> 2) - _Century + (_Century >> 2) + _Day_of_year - 719468};
}
};

Expand Down
60 changes: 39 additions & 21 deletions stl/inc/random
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,7 @@ public:
_Ty1 _Logp;
_Ty1 _Logp1;

_Small_poisson_distribution<_Ty> _Small;
_Small_poisson_distribution<_Ty> _Small; // TRANSITION, ABI: unused
};

binomial_distribution() : _Par(1, _Ty1(0.5)) {}
Expand Down Expand Up @@ -2505,8 +2505,26 @@ private:

return _Res;
} else if (_Par0._Mean < 1.0) {
// events are rare, use Poisson distribution
_Res = _Par0._Small(_Eng);
// Events are rare, use waiting time method (Luc Devroye, Non-Uniform Random Variate Generation, p. 525).
const _Ty1 _Rand = _NRAND(_Eng, _Ty1);

// The exit condition is log(1 - _Rand)/t < log(1-p), which is equivalent to _Rand > 1 - (1-p)^t. If
// we have a cheap upper bound for 1-(1-p)^t, we can exit early without having to call log. We use two
// such bounds, one that is tight for mean ~0 and another for mean ~1. In the first case, Bernoulli's
// inequality gives -1+p*t >= -(1-p)^t, so 1 - (1-p)^t <= p*t = mean. For the other bound, 1-(1-p)^t =
// 1-(1-p)(1-mean/t)^(t-1) <= 1-(1-p)(1-1/t)^(t-1) <= 1-(1-p)/e.
const _Ty1 _Ub =
(_STD min)(_Par0._Mean, _Ty1{3.678794411714423216e-1} * _Par0._Pp + _Ty1{6.32120558828557678e-1});
if (_Rand > _Ub) {
_Res = _Ty{0};
} else {
_Ty _Denom = _Par0._Tx;
_Ty1 _Sum = _CSTD log(_Ty1{1.0} - _Rand) / _Denom;
while (_Sum >= _Par0._Logp1 && --_Denom != 0) {
_Sum += _CSTD log(_Ty1{1.0} - _NRAND(_Eng, _Ty1)) / _Denom;
}
_Res = static_cast<_Ty>(_Par0._Tx - _Denom);
}
} else { // no shortcuts
using _Uty = make_unsigned_t<_Ty>;
const auto _Ty1_Tx{_Float_upper_bound<_Ty1>(static_cast<_Uty>(_Par0._Tx))};
Expand Down Expand Up @@ -2780,7 +2798,7 @@ public:
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down Expand Up @@ -2917,11 +2935,11 @@ public:
}

_NODISCARD result_type(min)() const { // get smallest possible result
return numeric_limits<result_type>::denorm_min();
return -numeric_limits<result_type>::infinity();
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() { // clear internal state
Expand Down Expand Up @@ -3057,7 +3075,7 @@ public:
}

_NODISCARD bool operator==(const param_type& _Right) const {
return _Px == _Right._Px;
return _Alpha == _Right._Alpha && _Beta == _Right._Beta;
}

_NODISCARD bool operator!=(const param_type& _Right) const {
Expand Down Expand Up @@ -3111,11 +3129,11 @@ public:
}

_NODISCARD result_type(min)() const { // get smallest possible result
return numeric_limits<result_type>::denorm_min();
return result_type{0.0};
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down Expand Up @@ -3306,7 +3324,7 @@ public:
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down Expand Up @@ -3438,11 +3456,11 @@ public:
}

_NODISCARD result_type(min)() const { // get smallest possible result
return (numeric_limits<result_type>::min)();
return -numeric_limits<result_type>::infinity();
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down Expand Up @@ -3576,11 +3594,11 @@ public:
}

_NODISCARD result_type(min)() const { // get smallest possible result
return -(numeric_limits<result_type>::max)();
return result_type{0.0};
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down Expand Up @@ -3702,11 +3720,11 @@ public:
}

_NODISCARD result_type(min)() const { // get smallest possible result
return numeric_limits<result_type>::denorm_min();
return result_type{0.0};
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down Expand Up @@ -3834,11 +3852,11 @@ public:
}

_NODISCARD result_type(min)() const { // get smallest possible result
return -(numeric_limits<result_type>::max)();
return -numeric_limits<result_type>::infinity();
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down Expand Up @@ -4035,7 +4053,7 @@ public:
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down Expand Up @@ -4168,11 +4186,11 @@ public:
}

_NODISCARD result_type(min)() const { // get smallest possible result
return -(numeric_limits<result_type>::max)();
return -numeric_limits<result_type>::infinity();
}

_NODISCARD result_type(max)() const { // get largest possible result
return (numeric_limits<result_type>::max)();
return numeric_limits<result_type>::infinity();
}

void reset() {} // clear internal state
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@ public:
_MyRe = nullptr;

#if _ITERATOR_DEBUG_LEVEL == 2
this->_Orphan_me();
this->_Orphan_me_v2();
#endif // _ITERATOR_DEBUG_LEVEL

return *this;
Expand Down
1 change: 1 addition & 0 deletions stl/inc/xhash
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,7 @@ protected:
}
}

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