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

2025-10-23


3099. Instantiation of type aliases from alias templates is unspecified

Section: 13.9.2  [temp.inst]     Status: open     Submitter: Hubert Tong     Date: 2025-10-23

(From submission #782.)

P2996 added the idea that a type alias can result from instantiation of an alias template; however, the timing of the instantiation (and its relation to the immediate context) is unspecified.

Consider:

  #include <meta>

  using namespace std::meta;

  template <typename T> using A = T *;

  template <auto> struct Sink;

  template <typename T> void f(Sink<^^A<T> > * = 0); // immediately instantiated and considered as part of the immediate context?
  template <typename T> void f(int = 0);
  void g() { f<int &>(); }

  constexpr auto x = substitute(^^A, {^^int &}); // valid until dealias?

Suggested resolution:

Change in 13.7.8 [temp.alias] paragraph 2 as follows:

A that designates the specialization of an alias template is equivalent to the associated type obtained by substitution of its template-arguments for the template-parameter s in the defining-type-id of the alias template. Any other template-id that names a specialization of an alias template is a typedef-name for a type alias; such a template-id is ill-formed if forming the associated type results in substitution failure. ...