Skip to content

callback: forward rvalue args - #950

Open
benedekkupper wants to merge 1 commit into
intel:mainfrom
benedekkupper:fix-callback-forwarding
Open

callback: forward rvalue args#950
benedekkupper wants to merge 1 commit into
intel:mainfrom
benedekkupper:fix-callback-forwarding

Conversation

@benedekkupper

Copy link
Copy Markdown

Preserve value category in callback::builder::run so services taking T&& receive rvalues instead of lvalues.
Add a regression test for callback::service<MoveOnlyPayload&&>.

Preserve value category in callback::builder::run so services
taking T&& receive rvalues instead of lvalues.
Add a regression test for callback::service<MoveOnlyPayload&&>.

Signed-off-by: Benedek Kupper <kupper.benedek@gmail.com>
@elbeno

elbeno commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

The reason it didn't do this before is that it's inside a fold expression. If there are multiple calllbacks you end up with a use-after-move.

@benedekkupper

Copy link
Copy Markdown
Author

The reason it didn't do this before is that it's inside a fold expression. If there are multiple calllbacks you end up with a use-after-move.

This is a valid concern and one that I pondered too, but without a better alternative in mind I went with it anyway (just adding a comment at the callback type definition). For correctness though it should either allow rvalue forwarding, or explicitly forbid it by a requires clause.

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.

2 participants