[WIP] libstdc++: Implement P0447R28, std::hive #224

Draft
tkaminsk wants to merge 1 commit from tkaminsk/gcc:tk/hive into trunk
First-time contributor
No description provided.
hive: Implement iteration, insertion and erasure
Some checks failed
/ format-checks (pull_request) Failing after 1m38s
6a9eeea6b3
Constructor and assigment are not implemented, as they depends
on above.
Member

Hi @tkaminsk. This bot helps send your PR as a patch series to the mailing list.

Next steps

  1. Write a clear PR description. It will be used as the cover letter.
  2. To CC extra people, add lines like this at the end of the PR description: CC: Reviewer1 <revi.ewer@example.com>, Reviewer2 <an.other@example.com>.
  3. To preview the emails, comment with /preview.
  4. When ready, request review in the Reviewers section. Or, if you just want to send the series, comment with /submit.
  5. Use the cover-letter links below to follow replies.
  6. For a new patch series, push your changes, update the PR description with a Changes since vX section, and comment with /submit again.

See Submitting Patches and UsingForge.

Consider joining the gcc and gcc-patches mailing lists..
For real time communication, check the gcc irc channels.

Or join #overseers on Libera Chat, particularly if this automation is not working (stay online to get replies, IRC does not save messages if people are not online).

<!-- pr-welcome --> Hi @tkaminsk. This bot helps send your PR as a patch series to the mailing list. ## Next steps 1. Write a clear PR description. It will be used as the cover letter. 2. To CC extra people, add lines like this **at the end** of the PR description: `CC: Reviewer1 <revi.ewer@example.com>, Reviewer2 <an.other@example.com>`. 3. To preview the emails, comment with `/preview`. 4. When ready, request review in the Reviewers section. Or, if you just want to send the series, comment with `/submit`. 5. Use the cover-letter links below to follow replies. 6. For a new patch series, push your changes, update the PR description with a `Changes since vX` section, and comment with `/submit` again. See [Submitting Patches](https://gcc.gnu.org/contribute.html#patches) and [UsingForge](https://gcc.gnu.org/wiki/UsingForge). Consider joining the [gcc and gcc-patches mailing lists.](https://gcc.gnu.org/lists.html). For real time communication, check the [gcc irc channels](https://gcc.gnu.org/wiki/GCConIRC). Or join [`#overseers`](https://web.libera.chat/#overseers) on Libera Chat, particularly if this automation is not working (stay online to get replies, IRC does not save messages if people are not online).
tkaminsk changed title from Implement P0447R28, std::hive to libstdc++: Implement P0447R28, std::hive 2026-08-25 10:15:57 +00:00
Member

Version 1 of this pull request has been stored. It includes the following commits:

  • hive: Implement iteration, insertion and erasure - 6a9eeea6b3
<!-- pr-new-version --> Version 1 of this pull request has been stored. It includes the following commits: - hive: Implement iteration, insertion and erasure - 6a9eeea6b3648750c3507c399319a1182ca1ded2
Implemented trim_capacity
Some checks failed
/ format-checks (pull_request) Failing after 1m37s
2b58fc6d8b
Member

Version 2 of this pull request has been stored. It includes the following commits:

  • hive: Implement iteration, insertion and erasure - 6a9eeea6b3
  • Implemented trim_capacity - 2b58fc6d8b
<!-- pr-new-version --> Version 2 of this pull request has been stored. It includes the following commits: - hive: Implement iteration, insertion and erasure - 6a9eeea6b3648750c3507c399319a1182ca1ded2 - Implemented trim_capacity - 2b58fc6d8b95b6263d7032ab4c5e90c8d2a8bf49
Member

Pull Request versions:

# Base Head
1 70ebcf89f8 6a9eeea6b3 (diff)
2 70ebcf89f8 2b58fc6d8b (diff)

In order to compare , clone this repository and run

PR=224
git fetch origin "refs/versioned_pull/${PR}/*:refs/versioned_pull/${PR}/*"
PRV1=1
PRV2=2
git range-diff "refs/versioned_pull/${PR}/${PRV1}/base..refs/versioned_pull/${PR}/${PRV1}/head"  "refs/versioned_pull/${PR}/${PRV2}/base..refs/versioned_pull/${PR}/${PRV2}/head"
<!-- pr-versions --> Pull Request versions: | # | Base | Head | | | - | ---- | ---- | - | | 1 | 70ebcf89f8534fe410163415f18c527b7b694b0b | 6a9eeea6b3648750c3507c399319a1182ca1ded2 | [(diff)](https://forge.sourceware.org/gcc/gcc.git/compare/70ebcf89f8534fe410163415f18c527b7b694b0b...6a9eeea6b3648750c3507c399319a1182ca1ded2) | | 2 | 70ebcf89f8534fe410163415f18c527b7b694b0b | 2b58fc6d8b95b6263d7032ab4c5e90c8d2a8bf49 | [(diff)](https://forge.sourceware.org/gcc/gcc.git/compare/70ebcf89f8534fe410163415f18c527b7b694b0b...2b58fc6d8b95b6263d7032ab4c5e90c8d2a8bf49) | In order to compare , clone this repository and run ``` PR=224 git fetch origin "refs/versioned_pull/${PR}/*:refs/versioned_pull/${PR}/*" PRV1=1 PRV2=2 git range-diff "refs/versioned_pull/${PR}/${PRV1}/base..refs/versioned_pull/${PR}/${PRV1}/head" "refs/versioned_pull/${PR}/${PRV2}/base..refs/versioned_pull/${PR}/${PRV2}/head" ```
Member
Cannot publish to mailing list as:

Pull request has no description and multiple commits.

<!-- pr-not-posted -->Cannot publish to mailing list as: Pull request has no description and multiple commits.
hive.cpp Outdated
@ -0,0 +1,144 @@
#include <iostream>
Member

I am not sure this file should be in the toplevel. Is this a testcase?

I am not sure this file should be in the toplevel. Is this a testcase?
Author
First-time contributor

Yes, but very in-promptu one that I used. Real test-cases needs to be added later.
Marked this as [WIP], as I used it to record current state, before pausing development.

Yes, but very in-promptu one that I used. Real test-cases needs to be added later. Marked this as [WIP], as I used it to record current state, before pausing development.
Author
First-time contributor

I have added now proper test covering all the cases from this file, and removed it.

I have added now proper test covering all the cases from this file, and removed it.
tkaminsk marked this conversation as resolved
Member
Cannot publish to mailing list as:

Pull request has no description and multiple commits.

<!-- pr-not-posted -->Cannot publish to mailing list as: Pull request has no description and multiple commits.
tkaminsk changed title from libstdc++: Implement P0447R28, std::hive to [WIP] libstdc++: Implement P0447R28, std::hive 2026-08-26 08:18:57 +00:00
tkaminsk force-pushed tk/hive from 2b58fc6d8b
Some checks failed
/ format-checks (pull_request) Failing after 1m37s
to c64c3b0756
Some checks failed
/ format-checks (pull_request) Failing after 1m22s
2026-09-15 13:51:23 +00:00
Compare
tkaminsk force-pushed tk/hive from 0b9233b60a
Some checks failed
/ format-checks (pull_request) Failing after 1m26s
to e02e00e52d
Some checks failed
/ format-checks (pull_request) Failing after 1m23s
2026-09-17 17:35:12 +00:00
Compare
tkaminsk force-pushed tk/hive from 1ed0c1ff8f
Some checks failed
/ format-checks (pull_request) Failing after 1m26s
to 8a73d7842e
Some checks failed
/ format-checks (pull_request) Failing after 1m23s
2026-09-18 08:18:14 +00:00
Compare
Remove ad-hoc test file, now fully covered by proper tests
Some checks failed
/ format-checks (pull_request) Failing after 1m19s
518f833170
tkaminsk force-pushed tk/hive from 518f833170
Some checks failed
/ format-checks (pull_request) Failing after 1m19s
to 2cc35d88e0
Some checks failed
/ format-checks (pull_request) Failing after 1m25s
2026-09-25 13:53:29 +00:00
Compare
tkaminsk force-pushed tk/hive from ac2d85685c
Some checks failed
/ format-checks (pull_request) Failing after 1m25s
to 3d8d4cfbe7
All checks were successful
/ format-checks (pull_request) Successful in 1m21s
2026-09-30 14:33:37 +00:00
Compare
tkaminsk force-pushed tk/hive from 3d8d4cfbe7
All checks were successful
/ format-checks (pull_request) Successful in 1m21s
to 1639705787
All checks were successful
/ format-checks (pull_request) Successful in 1m21s
2026-09-30 14:43:10 +00:00
Compare
libstdc++: Store pointer to slot in __hive::_Block.
All checks were successful
/ format-checks (pull_request) Successful in 1m18s
1a73c796eb
Instead of storing the pointer to start of the allocation (that includes
block), we include store pointer to begining of elements used for element
storage and it's offset from begining.

This leads to 30-40% precent of reduction in time time of iteration, but
still around 2x slower than deque.

libstdc++-v3/ChangeLog:

	* include/bits/hive.h (_Block::_M_mem_ptr): Remove.
	(_Block::_Block): Add __offset parameter.
	(_Block::_M_mem): Replace with _M_slots.
	(_Block::_M_slots): Replace _M_mem.
	(_Block::_M_offset): Define.
	(_Block::_M_memory, _Block::_M_slot): Adjust for above.
	(_Block_list::_S_allocate_block): Adjust call to constructor.
	(_Block_list::_S_deallocate_blocks): Use _M_offset.
libstdc++: Record number of free slots in the _Block.
All checks were successful
/ format-checks (pull_request) Successful in 1m20s
388d36c21e
Adds _M_free member to the _Block that tracks number of free slots
in the block. That allows the _M_clear_elems function to iteration
over elements when they are trivially destructible (and allocator
does not prived destroy).

This also allow to optimize the insertion for sized rangs, as we
now can more preciselly determine if the block will be filled
(and thus we do not need to compare iterator against end).

Finally, as we now know number of elements in block (_M_capacity -
_M_free), we can use sized insertion when transfer elements between
blocks during reshaping.

libstdc++-v3/ChangeLog:

	* include/bits/hive.h: ....
tkaminsk force-pushed tk/hive from 388d36c21e
All checks were successful
/ format-checks (pull_request) Successful in 1m20s
to 73049b0269
All checks were successful
/ format-checks (pull_request) Successful in 1m18s
2026-10-01 15:31:20 +00:00
Compare
tkaminsk force-pushed tk/hive from 73049b0269
All checks were successful
/ format-checks (pull_request) Successful in 1m18s
to e419eeecfb
All checks were successful
/ format-checks (pull_request) Successful in 1m21s
2026-10-06 11:57:54 +00:00
Compare
All checks were successful
/ format-checks (pull_request) Successful in 1m21s
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u tk/hive:tkaminsk-tk/hive
git switch tkaminsk-tk/hive

Merge

Merge the changes and update on Forgejo.
git switch trunk
git merge --no-ff tkaminsk-tk/hive
git switch tkaminsk-tk/hive
git rebase trunk
git switch trunk
git merge --ff-only tkaminsk-tk/hive
git switch tkaminsk-tk/hive
git rebase trunk
git switch trunk
git merge --no-ff tkaminsk-tk/hive
git switch trunk
git merge --squash tkaminsk-tk/hive
git switch trunk
git merge --ff-only tkaminsk-tk/hive
git switch trunk
git merge tkaminsk-tk/hive
git push origin trunk
Sign in to join this conversation.
No reviewers
gcc/Maintainers.libstdcplusplus
No milestone
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gcc/gcc!224
No description provided.