diff --git a/gtsam/inference/FactorGraphUnordered.h b/gtsam/inference/FactorGraphUnordered.h index f6c8f4cd5..d2ae08b8c 100644 --- a/gtsam/inference/FactorGraphUnordered.h +++ b/gtsam/inference/FactorGraphUnordered.h @@ -115,7 +115,8 @@ namespace gtsam { void push_back(const boost::shared_ptr& factor) { factors_.push_back(boost::shared_ptr(factor)); } - /** Add a factor, will be copy-constructed into a shared_ptr (use push_back to avoid the copy). */ + /** Add a factor by value, will be copy-constructed (use push_back with a shared_ptr to avoid + * the copy). */ template void add(const DERIVEDFACTOR& factor) { factors_.push_back(boost::make_shared(factor)); } @@ -130,16 +131,6 @@ namespace gtsam { push_back(ITERATOR firstFactor, ITERATOR lastFactor) { factors_.insert(end(), firstFactor, lastFactor); } - protected: - /** push back a BayesTree as a collection of factors. NOTE: This should be hidden in derived - * classes in favor of a type-specialized version that calls this templated function. */ - template - void push_back_bayesTree(const BayesTreeUnordered& bayesTree); - - template - void push_back(const DERIVEDFACTOR& factor) { - add(factor); } - /** push back many factors with an iterator over plain factors (factors are copied) */ template typename std::enable_if::value>::type @@ -148,6 +139,17 @@ namespace gtsam { add(*f); } + /** Add a factor by value, will be copy-constructed (pass a shared_ptr to avoid the copy). */ + template + void push_back(const DERIVEDFACTOR& factor) { + add(factor); } + + protected: + /** push back a BayesTree as a collection of factors. NOTE: This should be hidden in derived + * classes in favor of a type-specialized version that calls this templated function. */ + template + void push_back_bayesTree(const BayesTreeUnordered& bayesTree); + public: /** += syntax for push_back, e.g. graph += f1, f2, f3 */ template