Skip to content

<flat_map>: Restore use of push_back in flat_(multi)map::insert#5422

Merged
StephanTLavavej merged 1 commit intomicrosoft:feature/flat_mapfrom
frederick-vs-ja:flat_map-re-push_back
Apr 21, 2025
Merged

<flat_map>: Restore use of push_back in flat_(multi)map::insert#5422
StephanTLavavej merged 1 commit intomicrosoft:feature/flat_mapfrom
frederick-vs-ja:flat_map-re-push_back

Conversation

@frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Apr 21, 2025

libc++ tests seem to use some hostile sequence containers whose push_back have non-standard semantics for flat_meow. Per [sequence.reqmts]/104 and /108, this is unfortunately permitted, because push_back with the standard semantics is only required for basic_string, deque, inplace_vector, list, and vector.

AFAIK, most uses of flat container adaptors will use vector as the underlying containers. Also, every standard container adoptable for flat_meow has push_back with guaranteed semantics. So I think it's worthy enable push_back for the most usual uses.

Notes:

  • Partial specialization of _Has_guaranteed_push_back for list is deliberately missing because list isn't adoptable for flat_meow.
  • inplace_vector is not implemented yet so the partial specialization for it is missing.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner April 21, 2025 02:06
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Apr 21, 2025
@frederick-vs-ja frederick-vs-ja changed the title <flat_map>: Restore use of push_back in flat_(multi)map::insert` <flat_map>: Restore use of push_back in flat_(multi)map::insert Apr 21, 2025
@StephanTLavavej StephanTLavavej added bug Something isn't working flat_meow C++23 container adaptors labels Apr 21, 2025
@StephanTLavavej StephanTLavavej self-assigned this Apr 21, 2025
@StephanTLavavej StephanTLavavej added performance Must go faster and removed bug Something isn't working labels Apr 21, 2025
@StephanTLavavej
Copy link
Member

Ah, I see, this is an optimization to avoid the general codepath for insert-at-end, it is not for correctness.

@StephanTLavavej StephanTLavavej merged commit 2fabe62 into microsoft:feature/flat_map Apr 21, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Initial Review to Done in STL Code Reviews Apr 21, 2025
@StephanTLavavej
Copy link
Member

Thanks for figuring out how to combine performance with generality! 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flat_meow C++23 container adaptors performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants