Added one function emplace_shared

release/4.3a0
Yao Chen 2016-08-10 22:07:05 -04:00
parent f39cbf736d
commit 3d33b7e2cd
1 changed files with 9 additions and 1 deletions

View File

@ -33,6 +33,8 @@
#include <gtsam/base/FastVector.h>
#include <gtsam/inference/Key.h>
#include <utility>
namespace gtsam {
// Forward declarations
@ -159,6 +161,12 @@ namespace gtsam {
void push_back(const sharedFactor& factor) {
factors_.push_back(factor); }
/** Emplace a factor */
template<class DERIVEDFACTOR, class... Args>
void emplace_shared(Args&&... args) {
factors_.push_back(boost::make_shared<DERIVEDFACTOR>(std::forward<Args>(args)...));
}
/** push back many factors with an iterator over shared_ptr (factors are not copied) */
template<typename ITERATOR>
typename boost::enable_if<boost::is_base_of<FactorType, typename ITERATOR::value_type::element_type> >::type
@ -355,4 +363,4 @@ namespace gtsam {
} // namespace gtsam
#include <gtsam/inference/FactorGraph-inst.h>
#include <gtsam/inference/FactorGraph-inst.h>