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

Don't use inheritance for expression classes #35

Closed
vitaut opened this issue Feb 13, 2015 · 2 comments
Closed

Don't use inheritance for expression classes #35

vitaut opened this issue Feb 13, 2015 · 2 comments

Comments

@vitaut
Copy link
Contributor

vitaut commented Feb 13, 2015

This shouldn't be allowed, because it undermines type safety:

  auto n = factory_.MakeNumericConstant(42);
  auto u = factory_.MakeUnary(expr::ABS, n);
  mp::Expr &e = n;
  e = u;

So make expression classes independent types instantiated from a common template instead of using inheritance. This is similar to smart pointers and effectively expression classes are like smart pointers but with a nice API.

vitaut added a commit that referenced this issue Feb 13, 2015
vitaut added a commit that referenced this issue Feb 16, 2015
vitaut added a commit that referenced this issue Feb 17, 2015
@vitaut
Copy link
Contributor Author

vitaut commented Feb 17, 2015

Fixed for new expression types as of 02ca9fa. Need to do the same for ASL expressions.

vitaut added a commit that referenced this issue Feb 18, 2015
@vitaut
Copy link
Contributor Author

vitaut commented Feb 19, 2015

Complete in 449ba37.

@vitaut vitaut closed this as completed Feb 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant