Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constrained alias templates #39

Open
asutton opened this issue Jun 6, 2014 · 0 comments
Open

Constrained alias templates #39

asutton opened this issue Jun 6, 2014 · 0 comments
Labels

Comments

@asutton
Copy link
Contributor

asutton commented Jun 6, 2014

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.

@asutton asutton added the bug label Jun 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant