Skip to content

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

Closed
@xmh0511

Description

@xmh0511

[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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @xmh0511

        Issue actions

          [class.member.lookup] p7 Whether two conversion function (template)s correspond? · Issue #5387 · cplusplus/draft