From ab1148a508b66cba4ab71e0af3b111c22914375a Mon Sep 17 00:00:00 2001 From: dellaert Date: Mon, 29 Dec 2014 14:10:07 +0100 Subject: [PATCH] Added clone method --- gtsam/nonlinear/Expression.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gtsam/nonlinear/Expression.h b/gtsam/nonlinear/Expression.h index 3c9c4eeee..a39b1557c 100644 --- a/gtsam/nonlinear/Expression.h +++ b/gtsam/nonlinear/Expression.h @@ -170,6 +170,15 @@ public: return root_->value(values); } + /** + * @return a "deep" copy of this Expression + * "deep" is in quotes because the ExpressionNode hierarchy is *not* cloned. + * The intent is for derived classes to be copied using only a Base pointer. + */ + virtual boost::shared_ptr clone() const { + return boost::make_shared(*this); + } + private: /// Vaguely unsafe keys and dimensions in same order