Skip to content
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

[over.match.funcs.general] p4 direct member vs. member for defining the type of implicit object parameter #5361

Open
xmh0511 opened this issue Mar 25, 2022 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Mar 25, 2022

[over.match.funcs.general] p2 says

a member function that does not have an explicit object parameter is considered to have an extra first parameter, called the implicit object parameter, which represents the object for which the member function has been called.

[over.match.funcs.general] p4 says

where X is the class of which the function is a member and cv is the cv-qualification on the member function declaration.

Consider this example:

struct A{
   void show(){}
};
struct B:A{
};
B bobj;
bobj.show();

In this case, the object for which the member function show is called is bobj that is of type B. [class.derived.general] p2 says

Members of a base class are also members of the derived class.

That is, show is also a member of class B. So, whether the type of the implicit object parameter is considered to be A& or B&? The intent should be the former. [over.match.funcs.general] p4 might be changed to

where X is the class of which the function is a direct member

For conversion functions that are implicit object member functions, the function is considered to be a direct member of the class of the implied object argument for the purpose of defining the type of the implicit object parameter.

For non-conversion functions that are implicit object member functions nominated by a using-declaration in a derived class, the function is considered to be a direct member of the derived class for the purpose of defining the type of the implicit object parameter.

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

No branches or pull requests

1 participant