diff options
Diffstat (limited to 'impl/Expression.hpp')
-rw-r--r-- | impl/Expression.hpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/impl/Expression.hpp b/impl/Expression.hpp index 668f4fd..913bf7a 100644 --- a/impl/Expression.hpp +++ b/impl/Expression.hpp @@ -5,6 +5,9 @@ #include "VariableAssignment.hpp" #include "Operator.hpp" +template<typename T> +struct Variable; + int ExpressionCount; template<typename T> @@ -12,7 +15,9 @@ struct Expression { Expression(Operator<T>* op, const std::vector< Expression<T>* >& args) : _operator(op), _arguments(args) { } virtual ~Expression() { - delete _operator; + if (!dynamic_cast<Variable<T>*>(_operator)) { + delete _operator; + } } virtual T operator() (const VariableAssignment<T>& assignment) const { return (*_operator)(_arguments, assignment); @@ -52,4 +57,6 @@ struct MaxExpression : public Expression<T> { unsigned int _id; }; +#include "Variable.hpp" + #endif |