Skip to content

any_sender: add member connect() alongside tag_invoke(connect_t) friends#7292

Open
guptapratykshh wants to merge 1 commit into
TheHPXProject:masterfrom
guptapratykshh:feat/any_sender-member-connect
Open

any_sender: add member connect() alongside tag_invoke(connect_t) friends#7292
guptapratykshh wants to merge 1 commit into
TheHPXProject:masterfrom
guptapratykshh:feat/any_sender-member-connect

Conversation

@guptapratykshh
Copy link
Copy Markdown
Contributor

Proposed Changes

  • Add public member connect(R&&) overloads to unique_any_sender (rvalue-qualified) and any_sender (lvalue- and rvalue-qualified) in any_sender.hpp. The bodies are identical to the existing tag_invoke(connect_t, ...) friend bodies; stdexec's connect CPO prefers a member when one is present, so the dispatch path switches to the member while the friend remains as a delegate.
  • Refactor each of the three existing tag_invoke(connect_t, ...) friend overloads into one-line delegates to the corresponding member, so direct tag_invoke(connect_t{}, sender, r) calls and ADL-based discovery keep working unchanged.
  • No public-API removal, no API rename. The change is purely additive at the dispatch level and prepares the broader migration of execution_base's tag_invoke overloads toward stdexec-aligned member functions.

Any background context you want to provide?

Checklist

Not all points below apply to all pull requests.

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
@guptapratykshh guptapratykshh requested a review from hkaiser as a code owner May 23, 2026 17:23
Copilot AI review requested due to automatic review settings May 23, 2026 17:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds rvalue/lvalue-qualified connect member functions to any_sender and unique_any_sender, keeping existing tag_invoke(connect_t, ...) overloads as delegating shims for compatibility with ADL and direct tag_invoke calls.

Changes:

  • Introduced connect(R&&) & / connect(R&&) && member overloads for any_sender.
  • Introduced connect(R&&) && member overload for unique_any_sender.
  • Updated existing tag_invoke(connect_t, ...) friends to delegate to the new member connect overloads.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@StellarBot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

R&& r)
{
return HPX_MOVE(s).connect(HPX_FORWARD(R, r));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove the tag_invoke overloads now. @charan-003 could you confirm this, please?

Comment on lines +780 to +785
// Member connect overload (preferred by stdexec's connect CPO over
// the tag_invoke friend below). The CPO dispatches to the member
// when present, so this migration is purely additive -- the friend
// is kept as a thin delegate so existing direct
// tag_invoke(connect_t{}, ...) calls and ADL-based discovery keep
// working.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can drop this comment

Comment on lines +798 to +804
template <typename R>
friend detail::any_operation_state tag_invoke(
hpx::execution::experimental::connect_t, unique_any_sender&& s,
R&& r)
{
return HPX_MOVE(s).connect(HPX_FORWARD(R, r));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. tag_invoke is depricated
  2. connect_t already prefers .connect() https://en.cppreference.com/w/cpp/header/execution

Comment on lines +893 to +905
template <typename R>
friend detail::any_operation_state tag_invoke(
hpx::execution::experimental::connect_t, any_sender& s, R&& r)
{
return s.connect(HPX_FORWARD(R, r));
}

template <typename R>
friend detail::any_operation_state tag_invoke(
hpx::execution::experimental::connect_t, any_sender&& s, R&& r)
{
return HPX_MOVE(s).connect(HPX_FORWARD(R, r));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

friend only forwarded to member connect, so behavior is unchanged, and it will compile without those tag_invoke templates.

Comment on lines +869 to +873
// Member connect overloads (preferred by stdexec's connect CPO
// over the tag_invoke friends below). The friends are kept as
// thin delegates so existing direct tag_invoke(connect_t{}, ...)
// calls and ADL-based discovery keep working unchanged. See the
// matching pattern on unique_any_sender above.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can drop this as well

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants