cplusplus / cplusplus/draft

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

Open
#5,388 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with [temp.over.link] paragraph 6 and the cited rules for corresponding declarations. Compare the two function-template return types and the two conversion function-template names in the examples; done means the draft clearly specifies how these template-parameter-dependent types and names are compared.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.