From 3ccdf0b5ba5af503c612d0265138ba5836693ff6 Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:48:35 +0500 Subject: [PATCH 01/23] [xutility] make _Idl_distance constexpr --- stl/inc/xutility | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/xutility b/stl/inc/xutility index 3469d2b20fc..618163d56d9 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1330,7 +1330,7 @@ using _Enable_if_execution_policy_t = typename remove_reference_t<_ExPo>::_Stand // FUNCTION TEMPLATE _Idl_distance #if _HAS_IF_CONSTEXPR template -auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { +constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { // tries to get the distance between _First and _Last if they are random-access iterators if constexpr (_Is_random_iter_v<_Iter>) { return static_cast<_Iter_diff_t<_Checked>>(_Last - _First); @@ -1342,19 +1342,19 @@ auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { } #else // ^^^ _HAS_IF_CONSTEXPR / !_HAS_IF_CONSTEXPR vvv template -_Distance_unknown _Idl_distance1(const _Iter&, const _Iter&, input_iterator_tag) { +constexpr _Distance_unknown _Idl_distance1(const _Iter&, const _Iter&, input_iterator_tag) { // _Idl_distance for non-random-access iterators return {}; } template -_Iter_diff_t<_Checked> _Idl_distance1(const _Iter& _First, const _Iter& _Last, random_access_iterator_tag) { +constexpr _Iter_diff_t<_Checked> _Idl_distance1(const _Iter& _First, const _Iter& _Last, random_access_iterator_tag) { // _Idl_distance for random-access iterators return static_cast<_Iter_diff_t<_Checked>>(_Last - _First); } template -auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { +constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { // tries to get the distance between _First and _Last if they are random-access iterators return _Idl_distance1<_Checked>(_First, _Last, _Iter_cat_t<_Iter>()); } From 8a5c2536048fdbda7daf9288d6eb1245980a538b Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:48:47 +0500 Subject: [PATCH 02/23] [numeric] make accumulate constexpr --- stl/inc/numeric | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index e3cfe92777f..a8eb7fc05ea 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -23,7 +23,7 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN // FUNCTION TEMPLATE accumulate template -_NODISCARD _Ty accumulate(const _InIt _First, const _InIt _Last, _Ty _Val, _Fn _Reduce_op) { +_NODISCARD _CONSTEXPR20 _Ty accumulate(const _InIt _First, const _InIt _Last, _Ty _Val, _Fn _Reduce_op) { // return noncommutative and nonassociative reduction of _Val and all in [_First, _Last), using _Reduce_op _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -39,7 +39,7 @@ _NODISCARD _Ty accumulate(const _InIt _First, const _InIt _Last, _Ty _Val, _Fn _ } template -_NODISCARD _Ty accumulate(const _InIt _First, const _InIt _Last, _Ty _Val) { +_NODISCARD _CONSTEXPR20 _Ty accumulate(const _InIt _First, const _InIt _Last, _Ty _Val) { // return noncommutative and nonassociative reduction of _Val and all in [_First, _Last) return _STD accumulate(_First, _Last, _Val, plus<>()); } From 8799aa655087875601d087d8c9a20ea31e8460dc Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:49:08 +0500 Subject: [PATCH 03/23] [numeric] make inner_product constexpr --- stl/inc/numeric | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index a8eb7fc05ea..b79786f2d06 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -122,7 +122,7 @@ _NODISCARD _Iter_value_t<_FwdIt> reduce( // FUNCTION TEMPLATE inner_product template -_NODISCARD _Ty inner_product( +_NODISCARD _CONSTEXPR20 _Ty inner_product( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _Ty _Val, _BinOp1 _Reduce_op, _BinOp2 _Transform_op) { // return noncommutative and nonassociative transform-reduction of sequences, using // _Reduce_op and _Transform_op @@ -143,8 +143,8 @@ _NODISCARD _Ty inner_product( #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_NODISCARD _Ty inner_product(const _InIt1 _First1, const _InIt1 _Last1, _RightTy (&_First2)[_RightSize], _Ty _Val, - _BinOp1 _Reduce_op, _BinOp2 _Transform_op) { +_NODISCARD _CONSTEXPR20 _Ty inner_product(const _InIt1 _First1, const _InIt1 _Last1, _RightTy (&_First2)[_RightSize], + _Ty _Val, _BinOp1 _Reduce_op, _BinOp2 _Transform_op) { // return noncommutative and nonassociative transform-reduction of sequences, using // _Reduce_op and _Transform_op return _STD inner_product(_First1, _Last1, _Array_iterator<_RightTy, _RightSize>(_First2), _STD move(_Val), @@ -153,14 +153,15 @@ _NODISCARD _Ty inner_product(const _InIt1 _First1, const _InIt1 _Last1, _RightTy #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_NODISCARD _Ty inner_product(const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2, _Ty _Val) { +_NODISCARD _CONSTEXPR20 _Ty inner_product(const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2, _Ty _Val) { // return noncommutative and nonassociative transform-reduction of sequences return _STD inner_product(_First1, _Last1, _First2, _STD move(_Val), plus<>(), multiplies<>()); } #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_NODISCARD _Ty inner_product(const _InIt1 _First1, const _InIt1 _Last1, _RightTy (&_First2)[_RightSize], _Ty _Val) { +_NODISCARD _CONSTEXPR20 _Ty inner_product( + const _InIt1 _First1, const _InIt1 _Last1, _RightTy (&_First2)[_RightSize], _Ty _Val) { // return noncommutative and nonassociative transform-reduction of sequences return _STD inner_product(_First1, _Last1, _First2, _STD move(_Val), plus<>(), multiplies<>()); } From 7f1e166113b177f88564bd490587c2f51a124001 Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:49:30 +0500 Subject: [PATCH 04/23] [numeric] make partial_sum constexpr --- stl/inc/numeric | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index b79786f2d06..e80ab26d2a6 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -301,7 +301,7 @@ _NODISCARD _Ty transform_reduce(_ExPo&& _Exec, const _FwdIt _First1, const _FwdI // FUNCTION TEMPLATE partial_sum template -_OutIt partial_sum(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Reduce_op) { +_CONSTEXPR20 _OutIt partial_sum(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Reduce_op) { // compute partial noncommutative and nonassociative reductions into _Dest, using _Reduce_op _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -331,7 +331,7 @@ _OutIt partial_sum(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _ #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* partial_sum(_InIt _First, _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Reduce_op) { +_CONSTEXPR20 _DestTy* partial_sum(_InIt _First, _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Reduce_op) { // compute partial noncommutative and nonassociative reductions into _Dest, using _Reduce_op return _STD partial_sum(_First, _Last, _Array_iterator<_DestTy, _DestSize>(_Dest), _Pass_fn(_Reduce_op)) ._Unwrapped(); @@ -339,14 +339,14 @@ _DestTy* partial_sum(_InIt _First, _InIt _Last, _DestTy (&_Dest)[_DestSize], _Bi #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_OutIt partial_sum(_InIt _First, _InIt _Last, _OutIt _Dest) { +_CONSTEXPR20 _OutIt partial_sum(_InIt _First, _InIt _Last, _OutIt _Dest) { // compute partial noncommutative and nonassociative reductions into _Dest return _STD partial_sum(_First, _Last, _Dest, plus<>()); } #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* partial_sum(_InIt _First, _InIt _Last, _DestTy (&_Dest)[_DestSize]) { +_CONSTEXPR20 _DestTy* partial_sum(_InIt _First, _InIt _Last, _DestTy (&_Dest)[_DestSize]) { // compute partial noncommutative and nonassociative reductions into _Dest return _STD partial_sum(_First, _Last, _Dest, plus<>()); } From f1fc2e8b8eedbfea830fc7f9329213fec5b415e8 Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:49:44 +0500 Subject: [PATCH 05/23] [numeric] make exclusive_scan constexpr --- stl/inc/numeric | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index e80ab26d2a6..542d07bb59e 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -355,7 +355,7 @@ _CONSTEXPR20 _DestTy* partial_sum(_InIt _First, _InIt _Last, _DestTy (&_Dest)[_D #if _HAS_CXX17 // FUNCTION TEMPLATE exclusive_scan template -_OutIt exclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _Ty _Val, _BinOp _Reduce_op) { +_CONSTEXPR20 _OutIt exclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _Ty _Val, _BinOp _Reduce_op) { // set each value in [_Dest, _Dest + (_Last - _First)) to the associative reduction of predecessors and _Val _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -381,7 +381,7 @@ _OutIt exclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _Ty _ #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* exclusive_scan( +_CONSTEXPR20 _DestTy* exclusive_scan( const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _Ty _Val, _BinOp _Reduce_op) { // set each value in [_Dest, _Dest + (_Last - _First)) to the associative reduction of predecessors and _Val return _STD exclusive_scan( @@ -391,14 +391,14 @@ _DestTy* exclusive_scan( #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_OutIt exclusive_scan(const _InIt _First, const _InIt _Last, const _OutIt _Dest, _Ty _Val) { +_CONSTEXPR20 _OutIt exclusive_scan(const _InIt _First, const _InIt _Last, const _OutIt _Dest, _Ty _Val) { // set each value in [_Dest, _Dest + (_Last - _First)) to the associative reduction of predecessors and _Val return _STD exclusive_scan(_First, _Last, _Dest, _STD move(_Val), plus<>{}); } #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* exclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _Ty _Val) { +_CONSTEXPR20 _DestTy* exclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _Ty _Val) { // set each value in [_Dest, _Dest + (_Last - _First)) to the associative reduction of predecessors and _Val return _STD exclusive_scan(_First, _Last, _Dest, _STD move(_Val), plus<>{}); } From 085c5bcce6ef76e70566c1685da7418788a16cae Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:50:24 +0500 Subject: [PATCH 06/23] [numeric] make inclusive_scan constexpr --- stl/inc/numeric | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index 542d07bb59e..efdcb00e399 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -439,7 +439,7 @@ _DestTy* exclusive_scan(_ExPo&& _Exec, const _FwdIt1 _First, const _FwdIt1 _Last // FUNCTION TEMPLATE inclusive_scan template -_OutIt inclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Reduce_op, _Ty _Val) { +_CONSTEXPR20 _OutIt inclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Reduce_op, _Ty _Val) { // compute partial noncommutative and associative reductions including _Val into _Dest, using _Reduce_op _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -457,7 +457,7 @@ _OutIt inclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinO #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* inclusive_scan( +_CONSTEXPR20 _DestTy* inclusive_scan( const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Reduce_op, _Ty _Val) { // compute partial noncommutative and associative reductions including _Val into _Dest, using _Reduce_op return _STD inclusive_scan( @@ -467,7 +467,7 @@ _DestTy* inclusive_scan( #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_OutIt inclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Reduce_op) { +_CONSTEXPR20 _OutIt inclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Reduce_op) { // compute partial noncommutative and associative reductions into _Dest, using _Reduce_op _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -493,7 +493,8 @@ _OutIt inclusive_scan(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinO #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* inclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Reduce_op) { +_CONSTEXPR20 _DestTy* inclusive_scan( + const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Reduce_op) { // compute partial noncommutative and associative reductions into _Dest, using _Reduce_op return _STD inclusive_scan(_First, _Last, _Array_iterator<_DestTy, _DestSize>(_Dest), _Pass_fn(_Reduce_op)) ._Unwrapped(); @@ -501,14 +502,14 @@ _DestTy* inclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[ #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_OutIt inclusive_scan(const _InIt _First, const _InIt _Last, const _OutIt _Dest) { +_CONSTEXPR20 _OutIt inclusive_scan(const _InIt _First, const _InIt _Last, const _OutIt _Dest) { // compute partial noncommutative and associative reductions into _Dest return _STD inclusive_scan(_First, _Last, _Dest, plus<>{}); } #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* inclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize]) { +_CONSTEXPR20 _DestTy* inclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize]) { // compute partial noncommutative and associative reductions into _Dest return _STD inclusive_scan(_First, _Last, _Dest, plus<>{}); } From f19ca4909e88ce93f94c1fb8814b13c546ecc824 Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:50:39 +0500 Subject: [PATCH 07/23] [numeric] make transform_exclusive_scan constexpr --- stl/inc/numeric | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index efdcb00e399..d2a279ddb12 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -568,7 +568,7 @@ _DestTy* inclusive_scan( // FUNCTION TEMPLATE transform_exclusive_scan template -_OutIt transform_exclusive_scan( +_CONSTEXPR20 _OutIt transform_exclusive_scan( const _InIt _First, const _InIt _Last, _OutIt _Dest, _Ty _Val, _BinOp _Reduce_op, _UnaryOp _Transform_op) { // set each value in [_Dest, _Dest + (_Last - _First)) to the associative reduction of transformed predecessors _Adl_verify_range(_First, _Last); @@ -595,8 +595,8 @@ _OutIt transform_exclusive_scan( #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* transform_exclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _Ty _Val, - _BinOp _Reduce_op, _UnaryOp _Transform_op) { +_CONSTEXPR20 _DestTy* transform_exclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], + _Ty _Val, _BinOp _Reduce_op, _UnaryOp _Transform_op) { // set each value in [_Dest, _Dest + (_Last - _First)) to the associative reduction of transformed predecessors return _STD transform_exclusive_scan(_First, _Last, _Array_iterator<_DestTy, _DestSize>(_Dest), _STD move(_Val), _Pass_fn(_Reduce_op), _Pass_fn(_Transform_op)) From d8a8c2072635a4c428c52d97f47a5fd08887f391 Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:50:57 +0500 Subject: [PATCH 08/23] [numeric] make transform_inclusive_scan constexpr --- stl/inc/numeric | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index d2a279ddb12..0bb6c54356f 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -623,7 +623,7 @@ _DestTy* transform_exclusive_scan(_ExPo&& _Exec, const _FwdIt1 _First, const _Fw // FUNCTION TEMPLATE transform_inclusive_scan template -_OutIt transform_inclusive_scan( +_CONSTEXPR20 _OutIt transform_inclusive_scan( const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Reduce_op, _UnaryOp _Transform_op, _Ty _Val) { // compute partial noncommutative and associative transformed reductions including _Val into _Dest _Adl_verify_range(_First, _Last); @@ -642,8 +642,8 @@ _OutIt transform_inclusive_scan( #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* transform_inclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Reduce_op, - _UnaryOp _Transform_op, _Ty _Val) { +_CONSTEXPR20 _DestTy* transform_inclusive_scan(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], + _BinOp _Reduce_op, _UnaryOp _Transform_op, _Ty _Val) { // compute partial noncommutative and associative transformed reductions including _Val into _Dest return _STD transform_inclusive_scan(_First, _Last, _Array_iterator<_DestTy, _DestSize>(_Dest), _Pass_fn(_Reduce_op), _Pass_fn(_Transform_op), _STD move(_Val)) @@ -652,7 +652,7 @@ _DestTy* transform_inclusive_scan(const _InIt _First, const _InIt _Last, _DestTy #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_OutIt transform_inclusive_scan( +_CONSTEXPR20 _OutIt transform_inclusive_scan( const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Reduce_op, _UnaryOp _Transform_op) { // compute partial noncommutative and associative transformed reductions into _Dest _Adl_verify_range(_First, _Last); @@ -679,7 +679,7 @@ _OutIt transform_inclusive_scan( #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* transform_inclusive_scan( +_CONSTEXPR20 _DestTy* transform_inclusive_scan( const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Reduce_op, _UnaryOp _Transform_op) { // compute partial noncommutative and associative transformed reductions into _Dest return _STD transform_inclusive_scan( From b57032987c2561919477330f1201f828132bd18f Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:51:15 +0500 Subject: [PATCH 09/23] [numeric] make adjacent_difference constexpr --- stl/inc/numeric | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index 0bb6c54356f..df857d01164 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -725,7 +725,7 @@ _DestTy* transform_inclusive_scan(_ExPo&& _Exec, const _FwdIt1 _First, const _Fw // FUNCTION TEMPLATE adjacent_difference template -_OutIt adjacent_difference(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Func) { +_CONSTEXPR20 _OutIt adjacent_difference(const _InIt _First, const _InIt _Last, _OutIt _Dest, _BinOp _Func) { // compute adjacent differences into _Dest _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -753,7 +753,8 @@ _OutIt adjacent_difference(const _InIt _First, const _InIt _Last, _OutIt _Dest, #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* adjacent_difference(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Func) { +_CONSTEXPR20 _DestTy* adjacent_difference( + const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize], _BinOp _Func) { // compute adjacent differences into _Dest return _STD adjacent_difference(_First, _Last, _Array_iterator<_DestTy, _DestSize>(_Dest), _Pass_fn(_Func)) ._Unwrapped(); @@ -761,14 +762,14 @@ _DestTy* adjacent_difference(const _InIt _First, const _InIt _Last, _DestTy (&_D #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_OutIt adjacent_difference(const _InIt _First, const _InIt _Last, const _OutIt _Dest) { +_CONSTEXPR20 _OutIt adjacent_difference(const _InIt _First, const _InIt _Last, const _OutIt _Dest) { // compute adjacent differences into _Dest return _STD adjacent_difference(_First, _Last, _Dest, minus<>()); } #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_DestTy* adjacent_difference(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize]) { +_CONSTEXPR20 _DestTy* adjacent_difference(const _InIt _First, const _InIt _Last, _DestTy (&_Dest)[_DestSize]) { // compute adjacent differences into _Dest return _STD adjacent_difference(_First, _Last, _Dest, minus<>()); } From feaf2933cb6d6f1bb4ca26b96a6317ed805b4c9e Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 19 Dec 2019 19:51:21 +0500 Subject: [PATCH 10/23] [numeric] make iota constexpr --- stl/inc/numeric | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index df857d01164..f3e3f6216bf 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -811,7 +811,7 @@ _DestTy* adjacent_difference( // FUNCTION TEMPLATE iota template -void iota(_FwdIt _First, _FwdIt _Last, _Ty _Val) { +_CONSTEXPR20 void iota(_FwdIt _First, _FwdIt _Last, _Ty _Val) { // compute increasing sequence into [_First, _Last) _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); From c95af52e9a54ed21d546d601b52d6fc1ed7bc5b5 Mon Sep 17 00:00:00 2001 From: neargye Date: Fri, 20 Dec 2019 13:26:39 +0500 Subject: [PATCH 11/23] [yvals_core] define _CONSTEXPR20_ICE: Functions that became constexpr in C++20, and requires is_constant_evaluated --- stl/inc/yvals_core.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 77bc73dd7cc..9e4ee72e4bf 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -470,6 +470,13 @@ #define _CONSTEXPR20 inline #endif // ^^^ inline (not constexpr) in C++17 and earlier ^^^ +// Functions that became constexpr in C++20, and requires is_constant_evaluated +#ifdef __cpp_lib_is_constant_evaluated +#define _CONSTEXPR20_ICE constexpr +#else // ^^^ constexpr witn is_constant_evaluated / vvv inline (not constexpr) without is_constant_evaluated vvv +#define _CONSTEXPR20_ICE inline +#endif // ^^^ inline (not constexpr) without is_constant_evaluated ^^^ + // P0607R0 Inline Variables For The STL #if _HAS_CXX17 #define _INLINE_VAR inline From d777a928427247271e8a57251d03164d3f3454b5 Mon Sep 17 00:00:00 2001 From: neargye Date: Fri, 20 Dec 2019 14:42:40 +0500 Subject: [PATCH 12/23] [numeric] make reduce constexpr --- stl/inc/numeric | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index f3e3f6216bf..f670e15d157 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -70,31 +70,35 @@ inline constexpr bool _Plus_on_arithmetic_ranges_reduction_v = false; #endif // _STD_VECTORIZE_WITH_FLOAT_CONTROL template -_NODISCARD _Ty reduce(const _InIt _First, const _InIt _Last, _Ty _Val, _BinOp _Reduce_op) { +_NODISCARD _CONSTEXPR20_ICE _Ty reduce(const _InIt _First, const _InIt _Last, _Ty _Val, _BinOp _Reduce_op) { // return commutative and associative reduction of _Val and [_First, _Last), using _Reduce_op _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); if constexpr (_Plus_on_arithmetic_ranges_reduction_v<_Unwrapped_t, _Ty, _BinOp>) { - (void) _Reduce_op; // TRANSITION, VSO-486357 - return _Reduce_plus_arithmetic_ranges(_UFirst, _ULast, _Val); - } else { - for (; _UFirst != _ULast; ++_UFirst) { - _Val = _Reduce_op(_STD move(_Val), *_UFirst); // Requirement missing from N4713 +#ifdef __cpp_lib_is_constant_evaluated + if (!_STD is_constant_evaluated()) +#endif // __cpp_lib_is_constant_evaluated + { + (void) _Reduce_op; // TRANSITION, VSO-486357 + return _Reduce_plus_arithmetic_ranges(_UFirst, _ULast, _Val); } - - return _Val; } + for (; _UFirst != _ULast; ++_UFirst) { + _Val = _Reduce_op(_STD move(_Val), *_UFirst); // Requirement missing from N4713 + } + + return _Val; } template -_NODISCARD _Ty reduce(const _InIt _First, const _InIt _Last, _Ty _Val) { +_NODISCARD _CONSTEXPR20_ICE _Ty reduce(const _InIt _First, const _InIt _Last, _Ty _Val) { // return commutative and associative reduction of _Val and [_First, _Last) return _STD reduce(_First, _Last, _STD move(_Val), plus<>{}); } template -_NODISCARD _Iter_value_t<_InIt> reduce(const _InIt _First, const _InIt _Last) { +_NODISCARD _CONSTEXPR20_ICE _Iter_value_t<_InIt> reduce(const _InIt _First, const _InIt _Last) { // return commutative and associative reduction of // iterator_traits<_InIt>::value_type{} and [_First, _Last) return _STD reduce(_First, _Last, _Iter_value_t<_InIt>{}, plus<>{}); From b222525c96733f4f0c8142382d1c7d21bf2651fb Mon Sep 17 00:00:00 2001 From: neargye Date: Fri, 20 Dec 2019 14:42:53 +0500 Subject: [PATCH 13/23] [numeric] make transform_reduce constexpr --- stl/inc/numeric | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index f670e15d157..de60c1efb5a 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -197,7 +197,7 @@ inline constexpr bool _Default_ops_transform_reduce_v = false; #endif // _STD_VECTORIZE_WITH_FLOAT_CONTROL template -_NODISCARD _Ty transform_reduce( +_NODISCARD _CONSTEXPR20_ICE _Ty transform_reduce( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _Ty _Val, _BinOp1 _Reduce_op, _BinOp2 _Transform_op) { // return commutative and associative transform-reduction of sequences, using // _Reduce_op and _Transform_op @@ -207,22 +207,26 @@ _NODISCARD _Ty transform_reduce( auto _UFirst2 = _Get_unwrapped_n(_First2, _Idl_distance<_InIt1>(_UFirst1, _ULast1)); if constexpr (_Default_ops_transform_reduce_v<_Unwrapped_t, _Unwrapped_t, _Ty, _BinOp1, _BinOp2>) { - (void) _Reduce_op; // TRANSITION, VSO-486357 - (void) _Transform_op; // TRANSITION, VSO-486357 - return _Transform_reduce_arithmetic_defaults(_UFirst1, _ULast1, _UFirst2, _STD move(_Val)); - } else { - for (; _UFirst1 != _ULast1; ++_UFirst1, (void) ++_UFirst2) { - _Val = _Reduce_op(_STD move(_Val), _Transform_op(*_UFirst1, *_UFirst2)); // Requirement missing from N4713 +#ifdef __cpp_lib_is_constant_evaluated + if (!_STD is_constant_evaluated()) +#endif // __cpp_lib_is_constant_evaluated + { + (void) _Reduce_op; // TRANSITION, VSO-486357 + (void) _Transform_op; // TRANSITION, VSO-486357 + return _Transform_reduce_arithmetic_defaults(_UFirst1, _ULast1, _UFirst2, _STD move(_Val)); } - - return _Val; } + for (; _UFirst1 != _ULast1; ++_UFirst1, (void) ++_UFirst2) { + _Val = _Reduce_op(_STD move(_Val), _Transform_op(*_UFirst1, *_UFirst2)); // Requirement missing from N4713 + } + + return _Val; } #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_NODISCARD _Ty transform_reduce(const _InIt1 _First1, const _InIt1 _Last1, _RightTy (&_First2)[_RightSize], _Ty _Val, - _BinOp1 _Reduce_op, _BinOp2 _Transform_op) { +_NODISCARD _CONSTEXPR20_ICE _Ty transform_reduce(const _InIt1 _First1, const _InIt1 _Last1, + _RightTy (&_First2)[_RightSize], _Ty _Val, _BinOp1 _Reduce_op, _BinOp2 _Transform_op) { // return commutative and associative transform-reduction of // sequences, using _Reduce_op and _Transform_op return _STD transform_reduce(_First1, _Last1, _Array_iterator<_RightTy, _RightSize>(_First2), _STD move(_Val), @@ -231,21 +235,22 @@ _NODISCARD _Ty transform_reduce(const _InIt1 _First1, const _InIt1 _Last1, _Righ #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_NODISCARD _Ty transform_reduce(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _Ty _Val) { +_NODISCARD _CONSTEXPR20_ICE _Ty transform_reduce(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _Ty _Val) { // return commutative and associative transform-reduction of sequences return _STD transform_reduce(_First1, _Last1, _First2, _STD move(_Val), plus<>{}, multiplies<>{}); } #if _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_NODISCARD _Ty transform_reduce(_InIt1 _First1, _InIt1 _Last1, _RightTy (&_First2)[_RightSize], _Ty _Val) { +_NODISCARD _CONSTEXPR20_ICE _Ty transform_reduce( + _InIt1 _First1, _InIt1 _Last1, _RightTy (&_First2)[_RightSize], _Ty _Val) { // return commutative and associative transform-reduction of sequences return _STD transform_reduce(_First1, _Last1, _First2, _STD move(_Val), plus<>{}, multiplies<>{}); } #endif // _ITERATOR_DEBUG_ARRAY_OVERLOADS template -_NODISCARD _Ty transform_reduce( +_NODISCARD _CONSTEXPR20 _Ty transform_reduce( const _InIt _First, const _InIt _Last, _Ty _Val, _BinOp _Reduce_op, _UnaryOp _Transform_op) { // return commutative and associative reduction of transformed sequence, using // _Reduce_op and _Transform_op From 6dd3bac8755cc2eb665f6df0ea4b3340c4910d2c Mon Sep 17 00:00:00 2001 From: neargye Date: Fri, 20 Dec 2019 14:43:06 +0500 Subject: [PATCH 14/23] [yvals_core] define __cpp_lib_constexpr_numeric --- stl/inc/yvals_core.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 9e4ee72e4bf..dad72917128 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -165,6 +165,7 @@ // P1357R1 is_bounded_array, is_unbounded_array // P1456R1 Move-Only Views // P1612R1 Relocating endian To +// P1645R1 constexpr For Algorithms // P1651R0 bind_front() Should Not Unwrap reference_wrapper // P1690R1 Refining Heterogeneous Lookup For Unordered Containers // P1754R1 Rename Concepts To standard_case @@ -990,6 +991,7 @@ #endif // _HAS_STD_BOOLEAN #endif // defined(__cpp_concepts) && __cpp_concepts > 201507L +#define __cpp_lib_constexpr_numeric 201911L #define __cpp_lib_endian 201907L #define __cpp_lib_erase_if 201811L #define __cpp_lib_generic_unordered_lookup 201811L From eea82f2e9b093dcae6f01d591b3f84aae7c10dda Mon Sep 17 00:00:00 2001 From: neargye Date: Fri, 20 Dec 2019 17:04:30 +0500 Subject: [PATCH 15/23] [numeric] fix if(is_constant_evaluated()) --- stl/inc/numeric | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index de60c1efb5a..95e2fcc5855 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -75,20 +75,25 @@ _NODISCARD _CONSTEXPR20_ICE _Ty reduce(const _InIt _First, const _InIt _Last, _T _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); - if constexpr (_Plus_on_arithmetic_ranges_reduction_v<_Unwrapped_t, _Ty, _BinOp>) { #ifdef __cpp_lib_is_constant_evaluated - if (!_STD is_constant_evaluated()) + if (_STD is_constant_evaluated()) { + for (; _UFirst != _ULast; ++_UFirst) { + _Val = _Reduce_op(_STD move(_Val), *_UFirst); // Requirement missing from N4713 + } + return _Val; + } else #endif // __cpp_lib_is_constant_evaluated - { + { + if constexpr (_Plus_on_arithmetic_ranges_reduction_v<_Unwrapped_t, _Ty, _BinOp>) { (void) _Reduce_op; // TRANSITION, VSO-486357 return _Reduce_plus_arithmetic_ranges(_UFirst, _ULast, _Val); + } else { + for (; _UFirst != _ULast; ++_UFirst) { + _Val = _Reduce_op(_STD move(_Val), *_UFirst); // Requirement missing from N4713 + } + return _Val; } } - for (; _UFirst != _ULast; ++_UFirst) { - _Val = _Reduce_op(_STD move(_Val), *_UFirst); // Requirement missing from N4713 - } - - return _Val; } template @@ -205,22 +210,28 @@ _NODISCARD _CONSTEXPR20_ICE _Ty transform_reduce( auto _UFirst1 = _Get_unwrapped(_First1); const auto _ULast1 = _Get_unwrapped(_Last1); auto _UFirst2 = _Get_unwrapped_n(_First2, _Idl_distance<_InIt1>(_UFirst1, _ULast1)); - if constexpr (_Default_ops_transform_reduce_v<_Unwrapped_t, _Unwrapped_t, _Ty, - _BinOp1, _BinOp2>) { #ifdef __cpp_lib_is_constant_evaluated - if (!_STD is_constant_evaluated()) + if (_STD is_constant_evaluated()) { + for (; _UFirst1 != _ULast1; ++_UFirst1, (void) ++_UFirst2) { + _Val = _Reduce_op(_STD move(_Val), _Transform_op(*_UFirst1, *_UFirst2)); // Requirement missing from N4713 + } + return _Val; + } else #endif // __cpp_lib_is_constant_evaluated - { + { + if constexpr (_Default_ops_transform_reduce_v<_Unwrapped_t, _Unwrapped_t, _Ty, + _BinOp1, _BinOp2>) { (void) _Reduce_op; // TRANSITION, VSO-486357 (void) _Transform_op; // TRANSITION, VSO-486357 return _Transform_reduce_arithmetic_defaults(_UFirst1, _ULast1, _UFirst2, _STD move(_Val)); + } else { + for (; _UFirst1 != _ULast1; ++_UFirst1, (void) ++_UFirst2) { + _Val = + _Reduce_op(_STD move(_Val), _Transform_op(*_UFirst1, *_UFirst2)); // Requirement missing from N4713 + } + return _Val; } } - for (; _UFirst1 != _ULast1; ++_UFirst1, (void) ++_UFirst2) { - _Val = _Reduce_op(_STD move(_Val), _Transform_op(*_UFirst1, *_UFirst2)); // Requirement missing from N4713 - } - - return _Val; } #if _ITERATOR_DEBUG_ARRAY_OVERLOADS From 5044f97d3e7ef5c6cbfdeb31c9c2f0bacc1cfa02 Mon Sep 17 00:00:00 2001 From: Neargye Date: Fri, 20 Dec 2019 19:51:21 +0500 Subject: [PATCH 16/23] [yvals_core] remove inline from _CONSTEXPR20_ICE --- stl/inc/yvals_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index dad72917128..85088079544 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -474,9 +474,9 @@ // Functions that became constexpr in C++20, and requires is_constant_evaluated #ifdef __cpp_lib_is_constant_evaluated #define _CONSTEXPR20_ICE constexpr -#else // ^^^ constexpr witn is_constant_evaluated / vvv inline (not constexpr) without is_constant_evaluated vvv -#define _CONSTEXPR20_ICE inline -#endif // ^^^ inline (not constexpr) without is_constant_evaluated ^^^ +#else // ^^^ constexpr with is_constant_evaluated / vvv not constexpr without is_constant_evaluated vvv +#define _CONSTEXPR20_ICE +#endif // ^^^ not constexpr without is_constant_evaluated ^^^ // P0607R0 Inline Variables For The STL #if _HAS_CXX17 From d4dc329c19ff4f0906e3ad8558fc77715ad683b4 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Tue, 7 Jan 2020 19:32:49 -0800 Subject: [PATCH 17/23] Define _CONSTEXPR20_ICE in the right order. --- stl/inc/yvals_core.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index cda0d4372a9..ef7e9aa7096 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -471,13 +471,6 @@ #define _CONSTEXPR20 inline #endif // ^^^ inline (not constexpr) in C++17 and earlier ^^^ -// Functions that became constexpr in C++20, and requires is_constant_evaluated -#ifdef __cpp_lib_is_constant_evaluated -#define _CONSTEXPR20_ICE constexpr -#else // ^^^ constexpr with is_constant_evaluated / vvv not constexpr without is_constant_evaluated vvv -#define _CONSTEXPR20_ICE -#endif // ^^^ not constexpr without is_constant_evaluated ^^^ - // P0607R0 Inline Variables For The STL #if _HAS_CXX17 #define _INLINE_VAR inline @@ -1018,6 +1011,12 @@ #define __cpp_lib_experimental_erase_if 201411L #define __cpp_lib_experimental_filesystem 201406L +// Functions that became constexpr in C++20, and requires is_constant_evaluated +#ifdef __cpp_lib_is_constant_evaluated +#define _CONSTEXPR20_ICE constexpr +#else // ^^^ constexpr with is_constant_evaluated / vvv not constexpr without is_constant_evaluated vvv +#define _CONSTEXPR20_ICE +#endif // ^^^ not constexpr without is_constant_evaluated ^^^ #ifdef _RTC_CONVERSION_CHECKS_ENABLED #ifndef _ALLOW_RTCc_IN_STL From ca6a7c39c97386c10b81a1088229f23d166dc58b Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 8 Jan 2020 13:06:20 -0800 Subject: [PATCH 18/23] requires => require, remove vvv --- stl/inc/yvals_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index ef7e9aa7096..64f7171234f 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1011,10 +1011,10 @@ #define __cpp_lib_experimental_erase_if 201411L #define __cpp_lib_experimental_filesystem 201406L -// Functions that became constexpr in C++20, and requires is_constant_evaluated +// Functions that became constexpr in C++20, and require is_constant_evaluated #ifdef __cpp_lib_is_constant_evaluated #define _CONSTEXPR20_ICE constexpr -#else // ^^^ constexpr with is_constant_evaluated / vvv not constexpr without is_constant_evaluated vvv +#else // ^^^ constexpr with is_constant_evaluated / not constexpr without is_constant_evaluated vvv #define _CONSTEXPR20_ICE #endif // ^^^ not constexpr without is_constant_evaluated ^^^ From 4bd033b8d84ed45e40eacfe2f9f1090a1382b6e1 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 8 Jan 2020 13:11:01 -0800 Subject: [PATCH 19/23] Apply _NODISCARD to _Idl_distance. --- stl/inc/xutility | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/xutility b/stl/inc/xutility index 618163d56d9..d174decf2aa 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1330,7 +1330,7 @@ using _Enable_if_execution_policy_t = typename remove_reference_t<_ExPo>::_Stand // FUNCTION TEMPLATE _Idl_distance #if _HAS_IF_CONSTEXPR template -constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { +_NODISCARD constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { // tries to get the distance between _First and _Last if they are random-access iterators if constexpr (_Is_random_iter_v<_Iter>) { return static_cast<_Iter_diff_t<_Checked>>(_Last - _First); @@ -1342,19 +1342,19 @@ constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { } #else // ^^^ _HAS_IF_CONSTEXPR / !_HAS_IF_CONSTEXPR vvv template -constexpr _Distance_unknown _Idl_distance1(const _Iter&, const _Iter&, input_iterator_tag) { +_NODISCARD constexpr _Distance_unknown _Idl_distance1(const _Iter&, const _Iter&, input_iterator_tag) { // _Idl_distance for non-random-access iterators return {}; } template -constexpr _Iter_diff_t<_Checked> _Idl_distance1(const _Iter& _First, const _Iter& _Last, random_access_iterator_tag) { +_NODISCARD constexpr _Iter_diff_t<_Checked> _Idl_distance1(const _Iter& _First, const _Iter& _Last, random_access_iterator_tag) { // _Idl_distance for random-access iterators return static_cast<_Iter_diff_t<_Checked>>(_Last - _First); } template -constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { +_NODISCARD constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { // tries to get the distance between _First and _Last if they are random-access iterators return _Idl_distance1<_Checked>(_First, _Last, _Iter_cat_t<_Iter>()); } From 6fa436a1f817c29297ed28f5b59d6b38761a9b58 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 8 Jan 2020 13:36:34 -0800 Subject: [PATCH 20/23] Indicate that we are guarding `#pragma loop(ivdep)` due to DevCom-878972 --- stl/inc/numeric | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stl/inc/numeric b/stl/inc/numeric index 95e2fcc5855..7035c7e65f3 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -76,6 +76,7 @@ _NODISCARD _CONSTEXPR20_ICE _Ty reduce(const _InIt _First, const _InIt _Last, _T auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); #ifdef __cpp_lib_is_constant_evaluated + // TRANSITION, DevCom-878972 if (_STD is_constant_evaluated()) { for (; _UFirst != _ULast; ++_UFirst) { _Val = _Reduce_op(_STD move(_Val), *_UFirst); // Requirement missing from N4713 @@ -211,6 +212,7 @@ _NODISCARD _CONSTEXPR20_ICE _Ty transform_reduce( const auto _ULast1 = _Get_unwrapped(_Last1); auto _UFirst2 = _Get_unwrapped_n(_First2, _Idl_distance<_InIt1>(_UFirst1, _ULast1)); #ifdef __cpp_lib_is_constant_evaluated + // TRANSITION, DevCom-878972 if (_STD is_constant_evaluated()) { for (; _UFirst1 != _ULast1; ++_UFirst1, (void) ++_UFirst2) { _Val = _Reduce_op(_STD move(_Val), _Transform_op(*_UFirst1, *_UFirst2)); // Requirement missing from N4713 From 10aec6ccdedcedf368f235a0959f81f40f6954b9 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 8 Jan 2020 13:40:00 -0800 Subject: [PATCH 21/23] clang-format --- stl/inc/xutility | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stl/inc/xutility b/stl/inc/xutility index d174decf2aa..87d1f00599f 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1348,7 +1348,8 @@ _NODISCARD constexpr _Distance_unknown _Idl_distance1(const _Iter&, const _Iter& } template -_NODISCARD constexpr _Iter_diff_t<_Checked> _Idl_distance1(const _Iter& _First, const _Iter& _Last, random_access_iterator_tag) { +_NODISCARD constexpr _Iter_diff_t<_Checked> _Idl_distance1( + const _Iter& _First, const _Iter& _Last, random_access_iterator_tag) { // _Idl_distance for random-access iterators return static_cast<_Iter_diff_t<_Checked>>(_Last - _First); } From 8d6e17f77ed89c46c71e56e0538cc40f15528788 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 8 Jan 2020 17:24:07 -0800 Subject: [PATCH 22/23] Set the _CONSTEXPR20_ICE fallback to inline. --- stl/inc/yvals_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 64f7171234f..2b7a58adb7a 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1014,9 +1014,9 @@ // Functions that became constexpr in C++20, and require is_constant_evaluated #ifdef __cpp_lib_is_constant_evaluated #define _CONSTEXPR20_ICE constexpr -#else // ^^^ constexpr with is_constant_evaluated / not constexpr without is_constant_evaluated vvv -#define _CONSTEXPR20_ICE -#endif // ^^^ not constexpr without is_constant_evaluated ^^^ +#else // ^^^ constexpr with is_constant_evaluated / inline without is_constant_evaluated vvv +#define _CONSTEXPR20_ICE inline +#endif // __cpp_lib_is_constant_evaluated #ifdef _RTC_CONVERSION_CHECKS_ENABLED #ifndef _ALLOW_RTCc_IN_STL From 05cc659005ff14e071d62fde955f6eb80a7a480a Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 8 Jan 2020 17:31:30 -0800 Subject: [PATCH 23/23] Guard the __cpp_lib_constexpr_numeric macro for __cpp_lib_is_constant_evaluated. --- stl/inc/yvals_core.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 2b7a58adb7a..389c06219c8 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -984,7 +984,6 @@ #endif // _HAS_STD_BOOLEAN #endif // defined(__cpp_concepts) && __cpp_concepts > 201507L -#define __cpp_lib_constexpr_numeric 201911L #define __cpp_lib_endian 201907L #define __cpp_lib_erase_if 201811L #define __cpp_lib_generic_unordered_lookup 201811L @@ -1005,6 +1004,11 @@ #define __cpp_lib_to_array 201907L #define __cpp_lib_type_identity 201806L #define __cpp_lib_unwrap_ref 201811L + +#ifdef __cpp_lib_is_constant_evaluated +#define __cpp_lib_constexpr_numeric 201911L +#endif // __cpp_lib_is_constant_evaluated + #endif // _HAS_CXX20 // EXPERIMENTAL