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

[class.member.lookup] p7 Whether two conversion function (template)s correspond? #5387

Closed
xmh0511 opened this issue Apr 7, 2022 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Apr 7, 2022

[class.member.lookup] p7 says

If N is a non-dependent conversion-function-id, conversion function templates that are members of T are considered. For each such template F, the lookup set S(t ,T) is constructed, considering a function template declaration to have the name t only if it corresponds to a declaration of F ([basic.scope.scope]). The members of the declaration set of each such lookup set, which shall not be an invalid set, are included in the result.

Consider this example

struct A{
    template<class T>
    operator T();  // #1
};
struct B:A{
    template<class U>
    operator U&&();  // #2
};
B  b;
b.operator int();  // #3

Whether #1 corresponds to #2 is not clearly defined by [basic.scope.scope] p4 since the rule says

Two declarations correspond if they (re)introduce the same name, both declare constructors, or both declare destructors, unless

  • [...]
  • both declare function templates with equivalent non-object-parameter-type-lists, return types (if any), template-heads, and trailing requires-clauses (if any), and, if both are non-static members, they have corresponding object parameters.

About whether their types are equivalent, we define it in [temp.over.link] p6

When determining whether types or type-constraints are equivalent, the rules above are used to compare expressions involving template parameters.

Anyway, T and U&& that involve template parameters are not expressions. Moreover, this issue also exists for a common function template.

@xmh0511 xmh0511 closed this as completed Apr 8, 2022
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