Title
Equivalent types in function template declarations
Status
open
Section
13.7.7.2 [temp.over.link]
Submitter
Jim X

Created on 2022-04-08.00:00:00 last changed 24 months ago

Messages

Date: 2022-05-21.12:38:12

According to 6.4.1 [basic.scope.scope] paragraph 4:

Two declarations correspond if they (re)introduce the same name, both declare constructors, or both declare destructors, unless
  • ...
  • each declares a function or function template, except when
    • ...
    • 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.

Assuming that two non-object-parameter-type-lists are equivalent if they have the same length and corresponding types are equivalent, the question remains when two (possibly dependent) types are equivalent. Subclause 13.7.7.2 [temp.over.link] should provide an answer, but only covers expressions appearing in such types (paragraph 5):

Two expressions involving template parameters are considered equivalent if...

For example, the standard should specify whether these declarations correspond:

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

  template<class T, class U> void g(decltype(T::foo));
  template<class T, class U> void g(decltype(U::foo));

A related issue is the determination whether two names are the same; for example:

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

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

The latter issue could probably be fixed by amending 11.4.8.3 [class.conv.fct] to state that two conversion-function-ids are the same if their conversion-type-ids denote equivalent types, with a cross-reference to 13.7.7.2 [temp.over.link].

History
Date User Action Args
2022-04-08 00:00:00admincreate