Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iter_value_t<I> should always use direct-initialization #4233

Merged
merged 21 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
762947a
iter_value_t<I> should always use direct-initialization
fsb4000 Dec 3, 2023
eecac28
add more tests
fsb4000 Dec 4, 2023
b78ce8f
fix ranges::transform
fsb4000 Dec 5, 2023
4031def
Merge branch 'main' into fix4109
StephanTLavavej Jan 17, 2024
bb7c218
`using namespace std::execution;` => `using std::execution::par;`
StephanTLavavej Jan 18, 2024
88e5edc
`mt19937(1729)` => `extern mt19937 urbg;`
StephanTLavavej Jan 18, 2024
30062a4
Work around VSO-1941943 "Bogus warning C4700 (uninitialized local var…
StephanTLavavej Jan 18, 2024
53b8177
Remove unused headers.
StephanTLavavej Jan 18, 2024
b095712
Test classic `push_heap` and `pop_heap`.
StephanTLavavej Jan 18, 2024
32d0ef0
Test classic `uninitialized_move[_n]`.
StephanTLavavej Jan 18, 2024
b9a2593
Test parallel `uninitialized_MEOW`.
StephanTLavavej Jan 18, 2024
0185169
Test classic `lexicographical_compare_three_way`.
StephanTLavavej Jan 18, 2024
efe441d
`comp` => `pred2` when we aren't using less-than comparisons.
StephanTLavavej Jan 18, 2024
e4bfa4e
Test `ranges::nth_element` with optional `comp`.
StephanTLavavej Jan 18, 2024
28523b0
Follow N4971 synopsis order. Adjust newlines/comments, no other changes.
StephanTLavavej Jan 18, 2024
53c88ec
`using std::execution::par;` in Dev11_0253803_debug_pointer for consi…
StephanTLavavej Jan 18, 2024
02398b9
`always_true`/`always_false` => `pred`, this is compile-only.
StephanTLavavej Jan 18, 2024
392ca5d
No need to test `ranges::destroy`, `ranges::destroy_n`.
StephanTLavavej Jan 19, 2024
1b0bf4b
Test more overloads of parallel `inclusive_scan` and `transform_inclu…
StephanTLavavej Jan 19, 2024
16b5c85
Drop unnecessary argument variations - this is compile-only.
StephanTLavavej Jan 19, 2024
de4585e
Work around VSO-1946395 "/clr /std:c++20 /Od backend ICE for parallel…
StephanTLavavej Jan 24, 2024
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
28 changes: 14 additions & 14 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -4510,7 +4510,7 @@ _CONSTEXPR20 _OutIt unique_copy(_InIt _First, _InIt _Last, _OutIt _Dest, _Pr _Pr

++_UDest;
} else { // can't reread source or dest, construct a temporary
_Iter_value_t<_InIt> _Val = *_UFirst;
_Iter_value_t<_InIt> _Val(*_UFirst);

*_UDest = _Val;
++_UDest;
Expand Down Expand Up @@ -4637,7 +4637,7 @@ namespace ranges {
}
} else {
// Neither _First nor _Result can be reread, construct temporary
iter_value_t<_It> _Val = *_First;
iter_value_t<_It> _Val(*_First);

while (++_First != _Last) {
if (!_STD invoke(_Pred, _STD invoke(_Proj, _Val), _STD invoke(_Proj, *_First))) {
Expand Down Expand Up @@ -6293,7 +6293,7 @@ _CONSTEXPR20 void push_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) {
using _Diff = _Iter_diff_t<_RanIt>;
_Diff _Count = _ULast - _UFirst;
if (2 <= _Count) {
_Iter_value_t<_RanIt> _Val = _STD move(*--_ULast);
_Iter_value_t<_RanIt> _Val(_STD move(*--_ULast));
_STD _Push_heap_by_index(_UFirst, --_Count, _Diff(0), _STD move(_Val), _Pass_fn(_Pred));
}
}
Expand Down Expand Up @@ -6364,7 +6364,7 @@ namespace ranges {
}

--_Last;
iter_value_t<_It> _Val = _RANGES iter_move(_Last);
iter_value_t<_It> _Val(_RANGES iter_move(_Last));
// NB: if _Proj is a _Ref_fn, this aliases the _Proj1 and _Proj2 parameters of _Push_heap_by_index
_RANGES _Push_heap_by_index(_STD move(_First), _Count - 1, 0, _STD move(_Val), _Pred, _Proj, _Proj);
}
Expand Down Expand Up @@ -6420,7 +6420,7 @@ _CONSTEXPR20 void _Pop_heap_unchecked(_RanIt _First, _RanIt _Last, _Pr _Pred) {
// pop *_First to *(_Last - 1) and reheap
if (2 <= _Last - _First) {
--_Last;
_Iter_value_t<_RanIt> _Val = _STD move(*_Last);
_Iter_value_t<_RanIt> _Val(_STD move(*_Last));
_STD _Pop_heap_hole_unchecked(_First, _Last, _Last, _STD move(_Val), _Pred);
}
}
Expand Down Expand Up @@ -6498,7 +6498,7 @@ namespace ranges {
}

--_Last;
iter_value_t<_It> _Val = _RANGES iter_move(_Last);
iter_value_t<_It> _Val(_RANGES iter_move(_Last));
// NB: if _Proj is a _Ref_fn, this aliases the _Proj1 and _Proj2 parameters of _Pop_heap_hole_unchecked
_RANGES _Pop_heap_hole_unchecked(_STD move(_First), _Last, _Last, _STD move(_Val), _Pred, _Proj, _Proj);
}
Expand Down Expand Up @@ -6542,7 +6542,7 @@ _CONSTEXPR20 void _Make_heap_unchecked(_RanIt _First, _RanIt _Last, _Pr _Pred) {
for (_Diff _Hole = _Bottom >> 1; _Hole > 0;) { // shift for codegen
// reheap top half, bottom to top
--_Hole;
_Iter_value_t<_RanIt> _Val = _STD move(*(_First + _Hole));
_Iter_value_t<_RanIt> _Val(_STD move(*(_First + _Hole)));
_STD _Pop_heap_hole_by_index(_First, _Hole, _Bottom, _STD move(_Val), _Pred);
}
}
Expand All @@ -6569,7 +6569,7 @@ namespace ranges {
for (_Diff _Hole = _Bottom >> 1; _Hole > 0;) { // shift for codegen
// reheap top half, bottom to top
--_Hole;
iter_value_t<_It> _Val = _RANGES iter_move(_First + _Hole);
iter_value_t<_It> _Val(_RANGES iter_move(_First + _Hole));
// NB: if _Proj is a _Ref_fn, this aliases the _Proj1 and _Proj2 parameters of _Pop_heap_hole_by_index
_RANGES _Pop_heap_hole_by_index(_First, _Hole, _Bottom, _STD move(_Val), _Pred, _Proj, _Proj);
}
Expand Down Expand Up @@ -7833,8 +7833,8 @@ _CONSTEXPR20 _BidIt _Insertion_sort_unchecked(const _BidIt _First, const _BidIt
// insertion sort [_First, _Last)
if (_First != _Last) {
for (_BidIt _Mid = _First; ++_Mid != _Last;) { // order next element
_BidIt _Hole = _Mid;
_Iter_value_t<_BidIt> _Val = _STD move(*_Mid);
_BidIt _Hole = _Mid;
_Iter_value_t<_BidIt> _Val(_STD move(*_Mid));

if (_DEBUG_LT_PRED(_Pred, _Val, *_First)) { // found new earliest element, move to front
_Move_backward_unchecked(_First, _Mid, ++_Hole);
Expand Down Expand Up @@ -8022,8 +8022,8 @@ namespace ranges {
}

for (auto _Mid = _First; ++_Mid != _Last;) { // order next element
iter_value_t<_It> _Val = _RANGES iter_move(_Mid);
auto _Hole = _Mid;
iter_value_t<_It> _Val(_RANGES iter_move(_Mid));
auto _Hole = _Mid;

for (auto _Prev = _Hole;;) {
--_Prev;
Expand Down Expand Up @@ -8684,7 +8684,7 @@ _CONSTEXPR20 void partial_sort(_RanIt _First, _RanIt _Mid, _RanIt _Last, _Pr _Pr
_Make_heap_unchecked(_UFirst, _UMid, _Pass_fn(_Pred));
for (auto _UNext = _UMid; _UNext < _ULast; ++_UNext) {
if (_DEBUG_LT_PRED(_Pred, *_UNext, *_UFirst)) { // replace top with new largest
_Iter_value_t<_RanIt> _Val = _STD move(*_UNext);
_Iter_value_t<_RanIt> _Val(_STD move(*_UNext));
_STD _Pop_heap_hole_unchecked(_UFirst, _UMid, _UNext, _STD move(_Val), _Pass_fn(_Pred));
}
}
Expand Down Expand Up @@ -8774,7 +8774,7 @@ namespace ranges {
for (auto _Next = _Mid; _Next != _Last; ++_Next) {
if (_STD invoke(_Pred, _STD invoke(_Proj, *_Next), _STD invoke(_Proj, *_First))) {
// replace top with new largest
iter_value_t<_It> _Val = _RANGES iter_move(_Next);
iter_value_t<_It> _Val(_RANGES iter_move(_Next));
_RANGES _Pop_heap_hole_unchecked(_First, _Mid, _Next, _STD move(_Val), _Pred, _Proj, _Proj);
}
}
Expand Down
8 changes: 4 additions & 4 deletions stl/inc/numeric
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ _CONSTEXPR20 _OutIt inclusive_scan(const _InIt _First, const _InIt _Last, _OutIt
const auto _ULast = _Get_unwrapped(_Last);
auto _UDest = _Get_unwrapped_n(_Dest, _Idl_distance<_InIt>(_UFirst, _ULast));
if (_UFirst != _ULast) {
_Iter_value_t<_InIt> _Val = *_UFirst; // Requirement missing from N4950
_Iter_value_t<_InIt> _Val(*_UFirst); // Requirement missing from N4950
for (;;) {
*_UDest = _Val;
++_UDest;
Expand Down Expand Up @@ -476,10 +476,10 @@ _CONSTEXPR20 _OutIt adjacent_difference(const _InIt _First, const _InIt _Last, _
const auto _ULast = _Get_unwrapped(_Last);
auto _UDest = _Get_unwrapped_n(_Dest, _Idl_distance<_InIt>(_UFirst, _ULast));
if (_UFirst != _ULast) {
_Iter_value_t<_InIt> _Val = *_UFirst;
*_UDest = _Val;
_Iter_value_t<_InIt> _Val(*_UFirst);
*_UDest = _Val;
while (++_UFirst != _ULast) { // compute another difference
_Iter_value_t<_InIt> _Tmp = *_UFirst;
_Iter_value_t<_InIt> _Tmp(*_UFirst);
#if _HAS_CXX20
*++_UDest = _Func(_Tmp, _STD move(_Val));
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/random
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public:
const size_t _Mx = _Nx <= _Sx ? _Sx + 1 : _Nx;
size_t _Kx;

_Iter_value_t<_RanIt> _Mask = _Iter_value_t<_RanIt>(1) << 31;
_Iter_value_t<_RanIt> _Mask(_Iter_value_t<_RanIt>(1) << 31);
_Mask <<= 1; // build 32-bit mask safely
_Mask -= 1;

Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ tests\GH_003840_tellg_when_reading_lf_file_in_text_mode
tests\GH_003867_output_nan
tests\GH_004023_mdspan_fwd_prod_overflow
tests\GH_004040_container_nonmember_functions
tests\GH_004109_iter_value_t_direct_initialization
tests\LWG2381_num_get_floating_point
tests\LWG2597_complex_branch_cut
tests\LWG3018_shared_ptr_function
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\strict_concepts_20_matrix.lst
fsb4000 marked this conversation as resolved.
Show resolved Hide resolved
Loading