diff --git a/gtsam_unstable/nonlinear/Expression-inl.h b/gtsam_unstable/nonlinear/Expression-inl.h index a765177aa..f9401bf0f 100644 --- a/gtsam_unstable/nonlinear/Expression-inl.h +++ b/gtsam_unstable/nonlinear/Expression-inl.h @@ -327,7 +327,11 @@ public: } /// Return keys that play in this expression as a set - virtual std::set keys() const = 0; + virtual std::set keys() const { + std::set keys; + return keys; + } + // Return size needed for memory buffer in traceExecution size_t traceSize() const { @@ -362,12 +366,6 @@ class ConstantExpression: public ExpressionNode { public: - /// Return keys that play in this expression, i.e., the empty set - virtual std::set keys() const { - std::set keys; - return keys; - } - /// Return value virtual T value(const Values& values) const { return constant_; @@ -522,6 +520,14 @@ struct GenerateFunctionalNode: Argument, Base { static size_t const N = Base::N + 1; typedef Argument This; + /// Return keys that play in this expression + virtual std::set keys() const { + std::set keys = Base::keys(); + std::set myKeys = This::expression->keys(); + keys.insert(myKeys.begin(), myKeys.end()); + return keys; + } + }; /// Recursive GenerateFunctionalNode class Generator @@ -569,11 +575,6 @@ private: public: - /// Return keys that play in this expression - virtual std::set keys() const { - return this->template expression()->keys(); - } - /// Return value virtual T value(const Values& values) const { return function_(this->template expression()->value(values), boost::none); @@ -640,14 +641,6 @@ private: public: - /// Return keys that play in this expression - virtual std::set keys() const { - std::set keys1 = this->template expression()->keys(); - std::set keys2 = this->template expression()->keys(); - keys1.insert(keys2.begin(), keys2.end()); - return keys1; - } - /// Return value virtual T value(const Values& values) const { using boost::none; @@ -726,16 +719,6 @@ private: public: - /// Return keys that play in this expression - virtual std::set keys() const { - std::set keys1 = this->template expression()->keys(); - std::set keys2 = this->template expression()->keys(); - std::set keys3 = this->template expression()->keys(); - keys2.insert(keys3.begin(), keys3.end()); - keys1.insert(keys2.begin(), keys2.end()); - return keys1; - } - /// Return value virtual T value(const Values& values) const { using boost::none;