#ifndef EXPRESSION_REFERENCE_H #define EXPRESSION_REFERENCE_H #include "tree_reference.h" #include "expression_node.h" #include template class ExpressionReference : public TreeReference { public: ExpressionReference() : TreeReference() { } /*ExpressionReference(const ExpressionReference & er) { }*/ // Allow every ExpressionReference to be transformed into an ExpressionReference, i.e. Expression operator ExpressionReference() const { // TODO: make sure this is kosher // static_assert(sizeof(ExpressionReference) == sizeof(ExpressionReference), "All ExpressionReference are supposed to have the same size"); return *(reinterpret_cast *>(this)); } void addOperand(ExpressionReference e) { TreeReference::addChild(e); } ExpressionReference childAtIndex(int i) { return TreeReference::childAtIndex(i); } void replaceChildAtIndex(int oldChildIndex, ExpressionReference newChild) { TreeReference::replaceChildAtIndex(oldChildIndex, newChild); } float approximate() const { return this->node()->approximate(); } /* ExpressionReference simplify() { return node()->simplify(); } */ }; typedef ExpressionReference Expression; #endif