-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong
Reference (section label): [temp.alias], [temp.inst]
Link to reflector thread (if any): N/A
Issue description:
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.
Some thoughts:
- The "traditional" expansion of alias templates are in the immediate context, but the instantiation of class and function templates are not.
- Unlike classes and functions, it is not possible to declare a type alias without defining it (which may motivate "immediate" instantiation; which, in turn, reduces friction for an "immediate context" treatment).
Consider https://godbolt.org/z/Wof7fcr3a:
#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?Observations:
- Implementations are performing the instantiation even when the specialization is merely named for the purposes of producing a reflection (which, in theory, only requires the identity and not the instantiation of the specialization). This extends to the case where
substituteis used to form the specialization. - Implementations are treating the formation of the pointer-to-reference as being in the immediate context, which does not match the class/function template instantiation model.
Suggested resolution:
Gather input from P2996 paper authors.
Metadata
Metadata
Assignees
Labels
No labels