diff --git a/gtsam/nonlinear/Expression-inl.h b/gtsam/nonlinear/Expression-inl.h index 174fc31a6..5e262977a 100644 --- a/gtsam/nonlinear/Expression-inl.h +++ b/gtsam/nonlinear/Expression-inl.h @@ -537,7 +537,7 @@ struct FunctionalNode { template class UnaryExpression: public ExpressionNode { - typedef typename UnaryFunction::type Function; + typedef typename Expression::template UnaryFunction::type Function; Function function_; boost::shared_ptr > expression1_; @@ -679,7 +679,7 @@ public: private: - typedef typename BinaryFunction::type Function; + typedef typename Expression::template BinaryFunction::type Function; Function function_; /// Constructor with a ternary function f, and three input arguments @@ -729,7 +729,7 @@ class TernaryExpression: public FunctionalNode private: - typedef typename TernaryFunction::type Function; + typedef typename Expression::template TernaryFunction::type Function; Function function_; /// Constructor with a ternary function f, and three input arguments @@ -817,7 +817,7 @@ Expression::Expression(const Expression& expression, /// Construct a unary function expression template template -Expression::Expression(typename UnaryFunction::type function, +Expression::Expression(typename UnaryFunction::type function, const Expression& expression) : root_(new UnaryExpression(function, expression)) { } @@ -837,7 +837,7 @@ Expression::Expression(const Expression& expression1, /// Construct a binary function expression template template -Expression::Expression(typename BinaryFunction::type function, +Expression::Expression(typename BinaryFunction::type function, const Expression& expression1, const Expression& expression2) : root_(new BinaryExpression(function, expression1, expression2)) { } @@ -861,7 +861,7 @@ Expression::Expression(const Expression& expression1, template template Expression::Expression( - typename TernaryFunction::type function, + typename TernaryFunction::type function, const Expression& expression1, const Expression& expression2, const Expression& expression3) : root_( diff --git a/gtsam/nonlinear/Expression.h b/gtsam/nonlinear/Expression.h index c400fbe12..df575dbbf 100644 --- a/gtsam/nonlinear/Expression.h +++ b/gtsam/nonlinear/Expression.h @@ -43,30 +43,6 @@ template class ExpressionFactor; // For clarity, it is forward declared here but implemented at the end of this header. class JacobianMap; -// Expressions wrap trees of functions that can evaluate their own derivatives. -// The meta-functions below provide a handy to specify the type of those functions -template -struct UnaryFunction { - typedef boost::function< - T(const A1&, typename MakeOptionalJacobian::type)> type; -}; - -template -struct BinaryFunction { - typedef boost::function< - T(const A1&, const A2&, typename MakeOptionalJacobian::type, - typename MakeOptionalJacobian::type)> type; -}; - -template -struct TernaryFunction { - typedef boost::function< - T(const A1&, const A2&, const A3&, - typename MakeOptionalJacobian::type, - typename MakeOptionalJacobian::type, - typename MakeOptionalJacobian::type)> type; -}; - /// Storage type for the execution trace. /// It enforces the proper alignment in a portable way. /// Provide a traceSize() sized array of this type to traceExecution as traceStorage. @@ -91,6 +67,30 @@ private: public: + // Expressions wrap trees of functions that can evaluate their own derivatives. + // The meta-functions below provide a handy to specify the type of those functions + template + struct UnaryFunction { + typedef boost::function< + T(const A1&, typename MakeOptionalJacobian::type)> type; + }; + + template + struct BinaryFunction { + typedef boost::function< + T(const A1&, const A2&, typename MakeOptionalJacobian::type, + typename MakeOptionalJacobian::type)> type; + }; + + template + struct TernaryFunction { + typedef boost::function< + T(const A1&, const A2&, const A3&, + typename MakeOptionalJacobian::type, + typename MakeOptionalJacobian::type, + typename MakeOptionalJacobian::type)> type; + }; + /// Print void print(const std::string& s) const; @@ -113,7 +113,7 @@ public: /// Construct a unary function expression template - Expression(typename UnaryFunction::type function, + Expression(typename UnaryFunction::type function, const Expression& expression); /// Construct a unary method expression @@ -125,7 +125,7 @@ public: /// Construct a binary function expression template - Expression(typename BinaryFunction::type function, + Expression(typename BinaryFunction::type function, const Expression& expression1, const Expression& expression2); /// Construct a binary method expression @@ -139,7 +139,7 @@ public: /// Construct a ternary function expression template - Expression(typename TernaryFunction::type function, + Expression(typename TernaryFunction::type function, const Expression& expression1, const Expression& expression2, const Expression& expression3); diff --git a/gtsam/nonlinear/tests/testExpressionFactor.cpp b/gtsam/nonlinear/tests/testExpressionFactor.cpp index 94e32448c..900293261 100644 --- a/gtsam/nonlinear/tests/testExpressionFactor.cpp +++ b/gtsam/nonlinear/tests/testExpressionFactor.cpp @@ -327,7 +327,7 @@ TEST(ExpressionFactor, tree) { boost::shared_ptr gf2 = f2.linearize(values); EXPECT( assert_equal(*expected, *gf2, 1e-9)); - TernaryFunction::type fff = project6; + Expression::TernaryFunction::type fff = project6; // Try ternary version ExpressionFactor f3(model, measured, project3(x, p, K));