You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since constness in C++ is a shallow property (i.e. does not propagate downwards through nested datastructures), even with the new const visitor interface some class members of AST classes can still be changed. For example, for AST::BinaryOperator' the following operation is now prevented by the const` visitor:
One possible way to prevent this behavior is using std::experimental::propagate_const. We should evaluate if this is worth it. It has to work with gcc 8 since that is our target compiler.
Another much simpler option might be for the const getter of these classes to return a const shared_ptr<const T>.
The text was updated successfully, but these errors were encountered:
Since constness in C++ is a shallow property (i.e. does not propagate downwards through nested datastructures), even with the new const visitor interface some class members of AST classes can still be changed. For example, for AST::BinaryOperator' the following operation is now prevented by the const` visitor:
void visit(const std::shared_ptr& expr) override {
expr->getLeft() = expr->getRight();
The following unfortunately still compiles:
void visit(const std::shared_ptr& expr) override {
*(expr->getLeft()) = *(expr->getRight());
One possible way to prevent this behavior is using std::experimental::propagate_const. We should evaluate if this is worth it. It has to work with gcc 8 since that is our target compiler.
Another much simpler option might be for the const getter of these classes to return a
const shared_ptr<const T>
.The text was updated successfully, but these errors were encountered: