Repository navigation
Conversation
`__apply` and `__get` pass on each element of a forwarded `__tuple` by naming it as a member of the forwarded tuple, but naming a member of reference type gives an lvalue whatever the tuple's value category. So an element declared as `T &&` is passed on from a moved tuple as `T &`, although `__apply`'s constraint, `noexcept` and return type describe it as `T &&`, and `__get` already returns it as `T &&` from a tuple of more than eight elements. A function that can take only an rvalue can't be applied, and one that takes the element by value copies it instead of moving it. `exec::function` stores its curried arguments in a `__tuple<_Args...>`, so a `function` whose call type takes a curried argument of rvalue reference type, such as `function<std::string(std::string &&)>`, can be constructed but not connected: `connect` applies to the moved tuple a function that takes the argument as `std::string &&`. This diff casts each element to its declared type with the forwarded tuple's cvref-qualifiers, as `std::get` does and as `__structured_apply` already does, in `__apply` for tuples of every size and in `__get` for tuples of up to eight elements. Elements of value or lvalue reference type are passed on as before. The new tests check what `__apply` and `__get` give for elements of value, lvalue reference and rvalue reference type, from small and large tuples, and that a `function` passes its curried arguments to the factory as their declared types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ispeters
force-pushed
the
perfectly-forward-tuple
branch
from
October 29, 2026 02:31
70d2df8 to
21c9bb9
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
__applyand__getpass on each element of a forwarded__tupleby naming it as a member of the forwarded tuple, but naming a member of reference type gives an lvalue whatever the tuple's value category. So an element declared asT &&is passed on from a moved tuple asT &, although__apply's constraint,noexceptand return type describe it asT &&, and__getalready returns it asT &&from a tuple of more than eight elements. A function that can take only an rvalue can't be applied, and one that takes the element by value copies it instead of moving it.exec::functionstores its curried arguments in a__tuple<_Args...>, so afunctionwhose call type takes a curried argument of rvalue reference type, such asfunction<std::string(std::string &&)>, can be constructed but not connected:connectapplies to the moved tuple a function that takes the argument asstd::string &&.This diff casts each element to its declared type with the forwarded tuple's cvref-qualifiers, as
std::getdoes and as__structured_applyalready does, in__applyfor tuples of every size and in__getfor tuples of up to eight elements. Elements of value or lvalue reference type are passed on as before.The new tests check what
__applyand__getgive for elements of value, lvalue reference and rvalue reference type, from small and large tuples, and that afunctionpasses its curried arguments to the factory as their declared types.