-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
Description
A constrained alias templates constraints are not checked when the arguments are dependent. However, the alias is substituted at the point of use, before instantiation.
template<C T> using X = const T;
template<typename T>
void f(T x) {
X<T> y = x; // Potentially ill-formed
}
There are several ways an implementer might be able to check constraints:
- Require that constrained alias templates not be substituted on use. This is probably a non-starter.
- Propagate the constraints as part of the resulting type, basically inventing a new kind of "constrained type" that is valid only if the constraints are satsifed
- Do not check the constraints
Morally, the alias should not be used if its constraints are not subsumed by the constraints of the surrounding context since instantiation could lead to substitution failures. This is effectively the same as separate checking, which is most definitely not required by concepts lite.