From 6233902d500859087014c78da2e217504abec466 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 5 Mar 2023 10:20:56 -0800 Subject: [PATCH 1/4] Change `_Enabled = 0` to `= 0` for `countr_one()` and `_Popcount()`. There are no other declarations. --- stl/inc/bit | 2 +- stl/inc/limits | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/bit b/stl/inc/bit index b4ecd911d05..fffd7a7e1fe 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -314,7 +314,7 @@ _NODISCARD constexpr int countr_zero(const _Ty _Val) noexcept { return _Countr_zero(_Val); } -_EXPORT_STD template , int> _Enabled = 0> +_EXPORT_STD template , int> = 0> _NODISCARD constexpr int countr_one(const _Ty _Val) noexcept { return _Countr_zero(static_cast<_Ty>(~_Val)); } diff --git a/stl/inc/limits b/stl/inc/limits index 01e0f119c50..780fed2ae54 100644 --- a/stl/inc/limits +++ b/stl/inc/limits @@ -1231,7 +1231,7 @@ constexpr decltype(auto) _Select_countr_zero_impl(_Fn _Callback) { return _Callback([](_Ty _Val) { return _Countr_zero_fallback(_Val); }); } -template , int> _Enabled = 0> +template , int> = 0> _NODISCARD _CONSTEXPR20 int _Popcount(const _Ty _Val) noexcept { #if _HAS_POPCNT_INTRINSICS || _HAS_NEON_INTRINSICS #if _HAS_CXX20 From cc71c1925e7b1ea6926a923701e75d04c8a8ce42 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 5 Mar 2023 10:37:22 -0800 Subject: [PATCH 2/4] Change `_Enabled` to `/* = 0 */` for `duration_cast()`, `rotr()`, `countl_zero()`, and `swap()` for arrays. --- stl/inc/__msvc_chrono.hpp | 2 +- stl/inc/bit | 4 ++-- stl/inc/utility | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/__msvc_chrono.hpp b/stl/inc/__msvc_chrono.hpp index a68c871c7c0..4f4e5a1915e 100644 --- a/stl/inc/__msvc_chrono.hpp +++ b/stl/inc/__msvc_chrono.hpp @@ -417,7 +417,7 @@ namespace chrono { } #endif // defined(__cpp_lib_concepts) - _EXPORT_STD template , int> _Enabled> + _EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr _To duration_cast(const duration<_Rep, _Period>& _Dur) noexcept( is_arithmetic_v<_Rep>&& is_arithmetic_v) /* strengthened */ { // convert duration to another duration; truncate diff --git a/stl/inc/bit b/stl/inc/bit index fffd7a7e1fe..cb4252e53e8 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -117,7 +117,7 @@ _NODISCARD constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { } } -_EXPORT_STD template , int> _Enabled> +_EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; @@ -289,7 +289,7 @@ _NODISCARD constexpr unsigned long long _Byteswap_uint64(const unsigned long lon } #endif // _HAS_CXX23 -_EXPORT_STD template , int> _Enabled> +_EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr int countl_zero(const _Ty _Val) noexcept { #if defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) if (!_STD is_constant_evaluated()) { diff --git a/stl/inc/utility b/stl/inc/utility index f3bfe433fee..1e02dbb465e 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -78,7 +78,7 @@ _CONSTEXPR20 void iter_swap(_FwdIt1 _Left, _FwdIt2 _Right) { // swap *_Left and swap(*_Left, *_Right); } -_EXPORT_STD template ::value, int> _Enabled> +_EXPORT_STD template ::value, int> /* = 0 */> _CONSTEXPR20 void swap(_Ty (&_Left)[_Size], _Ty (&_Right)[_Size]) noexcept(_Is_nothrow_swappable<_Ty>::value) { if (&_Left != &_Right) { _Ty* _First1 = _Left; From 87bf2714f86f7ddf98727226b01dd5311a7c7a25 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 5 Mar 2023 10:39:30 -0800 Subject: [PATCH 3/4] Cleanup `swap(_Ty&, _Ty&)`. For C++17, follow the convention where the declaration is ` = 0` and the definition is `/* = 0 */`. For C++14, we want to emphasize the purpose of the second template parameter, so the declaration is `int _Enabled = 0` and the definition is `int _Enabled /* = 0 */`. --- stl/inc/utility | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/utility b/stl/inc/utility index 1e02dbb465e..b3e4858212c 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -91,9 +91,9 @@ _CONSTEXPR20 void swap(_Ty (&_Left)[_Size], _Ty (&_Right)[_Size]) noexcept(_Is_n } #if _HAS_CXX17 -_EXPORT_STD template && is_move_assignable_v<_Ty>, int> _Enabled> +_EXPORT_STD template && is_move_assignable_v<_Ty>, int> /* = 0 */> #else // ^^^ _HAS_CXX17 / !_HAS_CXX17 vvv -template +template #endif // _HAS_CXX17 _CONSTEXPR20 void swap(_Ty& _Left, _Ty& _Right) noexcept( is_nothrow_move_constructible_v<_Ty>&& is_nothrow_move_assignable_v<_Ty>) { From 0705d0a2d14e437428412aed89dc406c9076e9a3 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 5 Mar 2023 10:55:28 -0800 Subject: [PATCH 4/4] Add `/* = 0 */` to `tuple`'s ctors and `uses_allocator_construction_args()`. --- stl/inc/tuple | 4 ++-- stl/inc/xmemory | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/stl/inc/tuple b/stl/inc/tuple index de4ab093443..12efb5fb710 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -1009,13 +1009,13 @@ _NODISCARD constexpr const _Ty&& get(const tuple<_Types...>&& _Tuple) noexcept { } template -template , int>> +template , int> /* = 0 */> constexpr tuple<_This, _Rest...>::tuple(_Tag, _Tpl&& _Right, index_sequence<_Indices...>) : tuple(_Exact_args_t{}, _STD get<_Indices>(_STD forward<_Tpl>(_Right))...) {} template template , int>> + enable_if_t, int> /* = 0 */> constexpr tuple<_This, _Rest...>::tuple(_Tag, const _Alloc& _Al, _Tpl&& _Right, index_sequence<_Indices...>) : tuple(_Alloc_exact_args_t{}, _Al, _STD get<_Indices>(_STD forward<_Tpl>(_Right))...) {} diff --git a/stl/inc/xmemory b/stl/inc/xmemory index c809f772e96..40aa529c946 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -2331,7 +2331,7 @@ _NODISCARD constexpr auto uses_allocator_construction_args( _STD forward<_Tuple2>(_Tup2))); } -_EXPORT_STD template , int>> +_EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al) noexcept { // equivalent to // return _STD uses_allocator_construction_args<_Ty>(_Al, piecewise_construct, tuple<>{}, tuple<>{}); @@ -2339,7 +2339,7 @@ _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al) no _STD uses_allocator_construction_args(_Al)); } -_EXPORT_STD template , int>> +_EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al, _Uty1&& _Val1, _Uty2&& _Val2) noexcept { // equivalent to // return _STD uses_allocator_construction_args<_Ty>(_Al, piecewise_construct, @@ -2350,7 +2350,7 @@ _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al, _U } #if _HAS_CXX23 -_EXPORT_STD template , int>> +_EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al, pair<_Uty1, _Uty2>& _Pair) noexcept { // equivalent to // return _STD uses_allocator_construction_args<_Ty>(_Al, piecewise_construct, @@ -2361,7 +2361,7 @@ _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al, pa } #endif // _HAS_CXX23 -_EXPORT_STD template , int>> +_EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr auto uses_allocator_construction_args( const _Alloc& _Al, const pair<_Uty1, _Uty2>& _Pair) noexcept { // equivalent to @@ -2372,7 +2372,7 @@ _NODISCARD constexpr auto uses_allocator_construction_args( _STD uses_allocator_construction_args(_Al, _Pair.second)); } -_EXPORT_STD template , int>> +_EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al, pair<_Uty1, _Uty2>&& _Pair) noexcept { // equivalent to // return _STD uses_allocator_construction_args<_Ty>(_Al, piecewise_construct, @@ -2383,7 +2383,7 @@ _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al, pa } #if _HAS_CXX23 -_EXPORT_STD template , int>> +_EXPORT_STD template , int> /* = 0 */> _NODISCARD constexpr auto uses_allocator_construction_args( const _Alloc& _Al, const pair<_Uty1, _Uty2>&& _Pair) noexcept { // equivalent to @@ -2400,7 +2400,7 @@ _EXPORT_STD template requires _Is_cv_pair<_Ty> && (_Pair_like<_Uty> || !_Is_deducible_as_pair<_Uty&>) #else // ^^^ C++23 with concepts / C++20 or no concepts vvv _EXPORT_STD template && !_Is_deducible_as_pair<_Uty&>, int>> + enable_if_t<_Is_cv_pair<_Ty> && !_Is_deducible_as_pair<_Uty&>, int> /* = 0 */> #endif // ^^^ C++20 or no concepts ^^^ _NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al, _Uty&& _Ux) noexcept { #if _HAS_CXX23 && defined(__cpp_lib_concepts)