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

Use iterator concept in vector's range constructor #1794

Merged
merged 14 commits into from
Jun 12, 2022

Conversation

AdamBucior
Copy link
Contributor

Fixes #1709.

@AdamBucior AdamBucior requested a review from a team as a code owner March 31, 2021 17:55
@miscco
Copy link
Contributor

miscco commented Mar 31, 2021

Welcome to container hell, please take a seat

@miscco
Copy link
Contributor

miscco commented Mar 31, 2021

You might also have a look at _Assign_range

@AdamBucior
Copy link
Contributor Author

Could someone explain to me why move_iterator's iterator_concept is input_iterator_tag?

stl/inc/vector Outdated Show resolved Hide resolved
stl/inc/vector Show resolved Hide resolved
@StephanTLavavej StephanTLavavej added the performance Must go faster label Mar 31, 2021
@CaseyCarter CaseyCarter self-assigned this Mar 31, 2021
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After merging #1771, there are non-trivial merge conflicts in <vector>.

@AlexGuteniev
Copy link
Contributor

Also counts towards #189

@StephanTLavavej
Copy link
Member

Could someone explain to me why move_iterator's iterator_concept is input_iterator_tag?

I believe this is because a Forward Iterator can be read multiple times (the idea is that they're like forward_list - they support only forward traversal, but otherwise point to persistent objects in memory). Input Iterators can be read only once (like an istream_iterator, you can't store multiple "locations" to read previous values). move_iterator is weird because although it can wrap something with very strong traversal (up to and including random access), the automatic-moving breaks multi-read behavior. Thus, describing move_iterator with input_iterator_tag is the strictly correct thing to do.

Apologies for the year-long delay in answering this question 😹

@AdamBucior
Copy link
Contributor Author

@StephanTLavavej It seems that it might change with P2520.

@StephanTLavavej

This comment was marked as resolved.

stl/inc/vector Outdated Show resolved Hide resolved
stl/inc/vector Show resolved Hide resolved
@StephanTLavavej
Copy link
Member

Thanks, this looks great! I found only minor issues while video reviewing, so I went ahead and validated and pushed changes.

Copy link
Member

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting extension, since it's almost exactly the change WG21-P2408 will have us making to the non-permuting std algorithms for C++23. I think we're going to be seeing a lot of similar relaxations for "old" standard library code in C++26 as WG21 is getting our brains wrapped around where and how we can make these integrations without breaking programs in the wild.

@CaseyCarter CaseyCarter removed their assignment Jun 10, 2022
@StephanTLavavej StephanTLavavej self-assigned this Jun 10, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 877caba into microsoft:main Jun 12, 2022
@StephanTLavavej
Copy link
Member

Thanks for improving the performance of the STL's most important data structure! 😻 🚀 🚀

@AdamBucior AdamBucior deleted the vector-range-constructor branch June 12, 2022 10:27
fsb4000 pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
@drsnuggles8
Copy link

drsnuggles8 commented Oct 20, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance issue in handling range iterators in vector constructor
6 participants
  翻译: