-
Notifications
You must be signed in to change notification settings - Fork 1.6k
P1206R7 Conversions From Ranges To Containers #2806
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
Conversation
`<ranges>`: Implement `ranges::to`, guarded by `__cpp_lib_ranges_to_container`.
The following are all guarded by `__cpp_lib_containers_ranges`:
`<xmemory>`: Generalize `_Uninitialized_copy` to iterator+sentinel ranges; add `_Uninitialized_copy_n` for counted ranges. Implement `from_range_t`, `from_range`, and exposition-only helper concepts / type aliases.
`<xutility>`: Promote `_Get_final_iterator_unwrapped` here from `<algorithm>`. Add `_Copy_memmove_n` (`_Copy_n_unchecked`), similar to `_Copy_memmove` (resp. `_Copy_unchecked`) but for counted ranges. Generalize `_Iter_copy_cat` to `_Sent_copy_cat`.
`<memory>`: Use `_Copy_memmove_n` (see `<xutility>`) as appropriate.
`<yvals_core.h>`: `_HAS_CXX23` controls P1206R7, define `__cpp_lib_containers_ranges` and `__cpp_lib_ranges_to_container`.
`<deque>`: Implement `from_range_t` constructor(s) and corresponding deduction guide(s), `prepend_range`, `append_range`, `assign_range`, and `insert_range`.
`<forward_list>`: Implement `from_range_t` constructor(s) and corresponding deduction guide(s), `prepend_range`, `assign_range`, and `insert_range_after`.
`<list>`: Implement `from_range_t` constructor(s) and corresponding deduction guide(s), `prepend_range`, `append_range`, `assign_range`, and `insert_range`.
`<map>` and `<set>`: For both `map`, `multimap`, `set`, and `multiset`, implement `from_range_t` constructor(s) and corresponding deduction guide(s). (Inherit `insert_range` from `_Tree`.)
`<queue>`: For both `queue` and `priority_queue`, implement `from_range_t` constructor(s) and corresponding deduction guide(s), and `push_range`. (I've speculatively implemented `priority_queue::push_range` by calling `append_range` on the container per the resolution I've proposed for an LWG issue I submitted specifically to allow implementation via `append_range`.)
`<stack>`: Implement `from_range_t` constructor(s) and corresponding deduction guide(s), and `push_range`.
`<unordered_map>` and `<unordered_set>`: For both `unordered_map`, `unordered_multimap`, `unordered_set`, and `unordered_multiset`, implement `from_range_t` constructor(s) and corresponding deduction guide(s). (Inherit `insert_range` from `_Hash`.)
`<vector>`: For both `vector` and `vector<bool>`, implement `from_range_t` constructor(s) and corresponding deduction guide(s), `append_range`, `assign_range`, and `insert_range`.
`<xstring>`: For both `basic_string`, implement `from_range_t` constructor(s) and corresponding deduction guide(s), `append_range`, `assign_range`, `insert_range`, and `replace_with_range`.
Test both new feature-test macros in `tests/std/tests/VSO_0157762_feature_test_macros`.
Test all new deduction guides in `tests/std/tests/P0433R2_deduction_guides`.
Test `_Copy_n_unchecked` in `tests/std/tests/P0784R7_library_machinery`.
Add new t`P1206R7_{container}_{operation}` "range algorithm"-style tests for each new container (or container adapter) member function.
Add new `P1206R7_from_range` test for `from_range` and `from_range_t`.
Add new `P1206R7_ranges_to` test for `ranges::to`.
Fixes microsoft#2532.
StephanTLavavej
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are numerous real test failures - please investigate, fix, and verify before we begin reviewing this small PR. 😹
frederick-vs-ja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A strange value 202200L is used to test feature-test macros.
I have not idea why the test for deque failed now...
tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
frederick-vs-ja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't use _RERAISE again (see #2308).
…_after(pos, first, last)
miscco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review until ranges header
miscco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review until xstring
StephanTLavavej
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extremely partial video code review 😹
StephanTLavavej
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another partial video review 📺 and more progress! I've reviewed:
algorithmdequeforward_listlistxhash/unordered_map/unordered_setxtree/map/setxutilityyvals_core.h- feature-test macros test
tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
|
@CaseyCarter @strega-nil-ms I've pushed changes nicely structured as a series of commits for double-checking. Please meow if you have meows! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for keeping these short and simple - very easy to review. You know, compared to, say, a hypothetical 7,000 line change. |
... per resolution of just-submitted LWG issue.
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
Thanks for implementing this tiny feature - I believe that |
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
| && constructible_from<_Container, from_range_t, _Rng, _Types...>; | ||
| concept _Converts_tag_constructible = _Ref_converts<_Rng, _Container> | ||
| // per LWG issue unnumbered as of 2022-08-08 | ||
| && constructible_from<_Container, const from_range_t&, _Rng, _Types...>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this issue recently too.
And when I used MSVC-STL for resolution validation I found that you already dealt with it. Are you planning to file this LWG and stride_view::iterator::operator+= recently?

<ranges>: Implementranges::to, guarded by__cpp_lib_ranges_to_container.The following are all guarded by
__cpp_lib_containers_ranges:<xmemory>: Generalize_Uninitialized_copyto iterator+sentinel ranges; add_Uninitialized_copy_nfor counted ranges. Implementfrom_range_t,from_range, and exposition-only helper concepts / type aliases.<xutility>: Promote_Get_final_iterator_unwrappedhere from<algorithm>. Add_Copy_memmove_n(_Copy_n_unchecked), similar to_Copy_memmove(resp._Copy_unchecked) but for counted ranges. Generalize_Iter_copy_catto_Sent_copy_cat.<memory>: Use_Copy_memmove_n(see<xutility>) as appropriate.<yvals_core.h>:_HAS_CXX23controls P1206R7, define__cpp_lib_containers_rangesand__cpp_lib_ranges_to_container.<deque>: Implementfrom_range_tconstructor(s) and corresponding deduction guide(s),prepend_range,append_range,assign_range, andinsert_range.<forward_list>: Implementfrom_range_tconstructor(s) and corresponding deduction guide(s),prepend_range,assign_range, andinsert_range_after.<list>: Implementfrom_range_tconstructor(s) and corresponding deduction guide(s),prepend_range,append_range,assign_range, andinsert_range.<map>and<set>: For bothmap,multimap,set, andmultiset, implementfrom_range_tconstructor(s) and corresponding deduction guide(s). (Inheritinsert_rangefrom_Tree.)<queue>: For bothqueueandpriority_queue, implementfrom_range_tconstructor(s) and corresponding deduction guide(s), andpush_range. (I've speculatively implementedpriority_queue::push_rangeby callingappend_rangeon the container per the resolution I've proposed for an LWG issue I submitted specifically to allow implementation viaappend_range.)<stack>: Implementfrom_range_tconstructor(s) and corresponding deduction guide(s), andpush_range.<unordered_map>and<unordered_set>: For bothunordered_map,unordered_multimap,unordered_set, andunordered_multiset, implementfrom_range_tconstructor(s) and corresponding deduction guide(s). (Inheritinsert_rangefrom_Hash.)<vector>: For bothvectorandvector<bool>, implementfrom_range_tconstructor(s) and corresponding deduction guide(s),append_range,assign_range, andinsert_range.<xstring>: For bothbasic_string, implementfrom_range_tconstructor(s) and corresponding deduction guide(s),append_range,assign_range,insert_range, andreplace_with_range.Test both new feature-test macros in
tests/std/tests/VSO_0157762_feature_test_macros.Test all new deduction guides in
tests/std/tests/P0433R2_deduction_guides.Test
_Copy_n_uncheckedintests/std/tests/P0784R7_library_machinery.Add new t
P1206R7_{container}_{operation}"range algorithm"-style tests for each new container (or container adapter) member function.Add new
P1206R7_from_rangetest forfrom_rangeandfrom_range_t.Add new
P1206R7_ranges_totest forranges::to.Fixes #2532.