Skip to content

Comments

Improve allocator #2.#2

Merged
Dramcryx merged 1 commit intomasterfrom
dev/improve-allocator-2
Nov 26, 2025
Merged

Improve allocator #2.#2
Dramcryx merged 1 commit intomasterfrom
dev/improve-allocator-2

Conversation

@Dramcryx
Copy link
Owner

It turns out that compilers require movability for arguments passed by value (checked three majors in godbolt with cppcoro). Hence, if allocator is non-movable but copyable, it makes no sense for the new/delete - the coroutine itself won't compile. I decided to make new accept any Alloc that satisfies CoroutineAllocator concept just to make sure we receive no matter what type of allocator value/reference - we will copy it anyway.

It turns out that compilers require movability for arguments passed by value (checked three majors in godbolt with cppcoro).
Hence, if allocator is non-movable but copyable, it makes no sense for the `new`/`delete` - the coroutine itself won't compile.
I decieded to make `new` accept any `Alloc` that satisfies `CoroutineAllocator` concept just to make sure we receive no matter what type of allocator value/reference - we will copy it anyway.
@Dramcryx Dramcryx merged commit b05fe10 into master Nov 26, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant