Skip to content

[Feature Request]: Full member function support in BestOverloadFunctionMatch #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jeaye opened this issue May 24, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@jeaye
Copy link
Contributor

jeaye commented May 24, 2025

Description of new feature

I've found that BestOverloadFunctionMatch doesn't select any member function if one is const. It also doesn't support overloading based on & or &&.

struct bar
{
  int foo(int i)
  {
    return i;
  }

  int foo(int i) const
  {
    return i + 1;
  }
};

If the second foo is commented out, I can match the first member fn and call it no problem. But when both are present, neither matches.

This also brings up the important point that BestOverloadFunctionMatch doesn't take into account the constness or the value category of the invoking object. So matching const member fns or matching & or && member fns cannot be done without specifying more information to overload resolution.

I think we should be able to solve this by having the invoking object as the first argument and then resolve on that. Right now, BestOverloadFunctionMatch actually expects that it's not present. So, in my example above, the only argument would be one int.

If instead we need to provide a bar const& and int then we can match the overload on constness and value category of the invoking object.

@Vipul-Cariappa for vis.

@jeaye jeaye added the enhancement New feature or request label May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant