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

[temp.over.link] types involving template parameters are not expressions [CWG2584] #5388

Open
xmh0511 opened this issue Apr 8, 2022 · 5 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Apr 8, 2022

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.

we define whether two types are equivalent in [temp.over.link] p6, which says

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

Consider this example:

template<class T>
T fun();

template<class T>
T&& fun();

In this example, their return types are T and T&&, which involve template parameters. However, T and T&& are not expressions anyway. According to grammar, they are defined as type-specifier. So, whether two function templates correspond relies on the correct definition of [temp.over.link], the latter seems to be a bit clear in its definition.


Another special case is the conversion function template whose name involves template parameter

struct A{
   template<class T>
   operator T();

   template<class T>
   operator T&&();
};

Such two conversion function templates' names are operator T and operator T&&, respectively. whether they declare the same name or not is unclear in this document. For this issue, I think we may clarify it with the help of equivalent return types.

@xmh0511 xmh0511 changed the title [temp.over.link] types involving template parameters are not expression [temp.over.link] types involving template parameters are not expressions Apr 8, 2022
@xmh0511 xmh0511 changed the title [temp.over.link] types involving template parameters are not expressions [temp.over.link] types involving template parameters are not expressions [CWG2584] May 5, 2022
@xmh0511
Copy link
Contributor Author

xmh0511 commented May 5, 2022

@jensmaurer CWG2584 only covers the first case(namely, whether two types are equivalent). The second case is not covered(namely, whether two names involving template parameters are the same).

@jensmaurer
Copy link
Member

I've fixed CWG2584.

@xmh0511
Copy link
Contributor Author

xmh0511 commented May 5, 2022

Thanks. Please add T vs. T&& example(if possible). The current added example decltype(T::foo) and decltype(U::foo) may arguably be said to that T::foo and U::foo thereof are expressions(involving template parameters). I want to say T and T&& are just type-specifiers that don't touch expressions at all, which can directly expose the subject.

@jensmaurer
Copy link
Member

Done.

@xmh0511
Copy link
Contributor Author

xmh0511 commented May 5, 2022

Thank you.

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