This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115g. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-16


2584. Equivalent types in function template declarations

Section: 13.7.7.2  [temp.over.link]     Status: open     Submitter: Jim X     Date: 2022-04-08

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

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