diff --git a/gtsam_unstable/nonlinear/Expression-inl.h b/gtsam_unstable/nonlinear/Expression-inl.h index f9401bf0f..75407fb54 100644 --- a/gtsam_unstable/nonlinear/Expression-inl.h +++ b/gtsam_unstable/nonlinear/Expression-inl.h @@ -332,7 +332,6 @@ public: return keys; } - // Return size needed for memory buffer in traceExecution size_t traceSize() const { return traceSize_; @@ -537,8 +536,8 @@ struct FunctionalNode: public boost::mpl::fold, /// Access Expression template - boost::shared_ptr > expression() { - return static_cast &>(*this).expression; + void reset(const boost::shared_ptr >& ptr) { + static_cast &>(*this).expression = ptr; } /// Access Expression, const version @@ -567,7 +566,7 @@ private: /// Constructor with a unary function f, and input argument e UnaryExpression(Function f, const Expression& e1) : function_(f) { - this->template expression() = e1.root(); + this->template reset(e1.root()); ExpressionNode::traceSize_ = sizeof(Record) + e1.traceSize(); } @@ -630,8 +629,8 @@ private: BinaryExpression(Function f, const Expression& e1, const Expression& e2) : function_(f) { - this->template expression() = e1.root(); - this->template expression() = e2.root(); + this->template reset(e1.root()); + this->template reset(e2.root()); ExpressionNode::traceSize_ = // sizeof(Record) + e1.traceSize() + e2.traceSize(); } @@ -645,8 +644,8 @@ public: virtual T value(const Values& values) const { using boost::none; return function_(this->template expression()->value(values), - this->template expression()->value(values), - none, none); + this->template expression()->value(values), + none, none); } /// Return value and derivatives @@ -678,7 +677,6 @@ public: raw = raw + this->template expression()->traceSize(); A2 a2 = this->template expression()->traceExecution(values, record->template trace(), raw); - raw = raw + this->template expression()->traceSize(); return function_(a1, a2, record->template jacobian(), record->template jacobian()); @@ -708,9 +706,9 @@ private: TernaryExpression(Function f, const Expression& e1, const Expression& e2, const Expression& e3) : function_(f) { - this->template expression() = e1.root(); - this->template expression() = e2.root(); - this->template expression() = e3.root(); + this->template reset(e1.root()); + this->template reset(e2.root()); + this->template reset(e3.root()); ExpressionNode::traceSize_ = // sizeof(Record) + e1.traceSize() + e2.traceSize() + e3.traceSize(); } @@ -723,9 +721,9 @@ public: virtual T value(const Values& values) const { using boost::none; return function_(this->template expression()->value(values), - this->template expression()->value(values), - this->template expression()->value(values), - none, none, none); + this->template expression()->value(values), + this->template expression()->value(values), + none, none, none); } /// Return value and derivatives