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

The reference of a conversion function(template) with a deduced return type #4671

Closed
xmh0511 opened this issue Jun 9, 2021 · 6 comments
Closed

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jun 9, 2021

In N4861, the relevant rule temp.mem#5 is:

A specialization of a conversion function template is referenced in the same way as a non-template conversion function that converts to the same type.

After P1787, the above normative rule is radically changed to be a note

[Note 1: A specialization of a conversion function template is referenced in the same way as a non-template conversion function that converts to the same type ([class.conv.fct]).

There's no normative rule based on to interpret why we should use a.operator int*(); to refer to the specialization. I also feel that this issue is similar with How to explicitly call a conversion function whose conversion-type-id contains a placeholder specifier that I have posted it to wmm@edg.com, which has became the issue 2493 that will be published on http://open-std.org/jtc1/sc22/wg21/

@jensmaurer
Copy link
Member

Duplicate of #4811 CWG2493.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Aug 13, 2021

@jensmaurer It is a bit similar to #4811 but not completely. One is template function, the other is a function with place-holder return type.

@jensmaurer
Copy link
Member

Agreed.

The rationale for the conversion function template case is that the deduction that needs to happen here is part of name lookup. [class.member.lookup] p7

@xmh0511
Copy link
Contributor Author

xmh0511 commented Aug 13, 2021

@jensmaurer So, I think it should be an individual issue that should be processed. After all, the deduction of a conversion function template occurs as a part of name lookup and that is deduced with the actual argument. Instead, the conversion function with the place-holder is directly deduced from its return statement.

@jensmaurer
Copy link
Member

I'm saying the normative rule for the template case is in [class.member.lookup] p7. If you feel that's insufficient, please give more details. And fix the heading if this particular issue is not about deduced return types, but just about conversion function templates.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Aug 13, 2021

@jensmaurer After further consideration, you're right. [class.member.lookup] p7 has clarified this.

struct A {
  template <class T> operator T*();
};
A a;
int* ip = a.operator int*();

a.operator int*() may be the only way to refer to that specialization.

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

2 participants