diff --git a/gtsam/hybrid/HybridGaussianISAM.cpp b/gtsam/hybrid/HybridGaussianISAM.cpp index 0462d7998..0dd5fa38b 100644 --- a/gtsam/hybrid/HybridGaussianISAM.cpp +++ b/gtsam/hybrid/HybridGaussianISAM.cpp @@ -89,7 +89,7 @@ void HybridGaussianISAM::updateInternal( // Add the orphaned subtrees for (const sharedClique& orphan : *orphans) { - factors.push_back(std::make_shared>(orphan)); + factors.emplace_shared>(orphan); } const VariableIndex index(factors); diff --git a/gtsam/inference/ISAM-inst.h b/gtsam/inference/ISAM-inst.h index aaebf9385..dc0750b72 100644 --- a/gtsam/inference/ISAM-inst.h +++ b/gtsam/inference/ISAM-inst.h @@ -41,7 +41,7 @@ void ISAM::updateInternal(const FactorGraphType& newFactors, // Add the orphaned subtrees for (const sharedClique& orphan : *orphans) - factors.push_back(std::make_shared >(orphan)); + factors.template emplace_shared >(orphan); // Get an ordering where the new keys are eliminated last const VariableIndex index(factors); diff --git a/gtsam/nonlinear/NonlinearFactorGraph.h b/gtsam/nonlinear/NonlinearFactorGraph.h index 92bfdaf20..cf2565725 100644 --- a/gtsam/nonlinear/NonlinearFactorGraph.h +++ b/gtsam/nonlinear/NonlinearFactorGraph.h @@ -189,7 +189,7 @@ namespace gtsam { template void addExpressionFactor(const SharedNoiseModel& R, const T& z, const Expression& h) { - push_back(std::make_shared >(R, z, h)); + this->emplace_shared>(R, z, h); } /** diff --git a/gtsam/slam/tests/testGeneralSFMFactor.cpp b/gtsam/slam/tests/testGeneralSFMFactor.cpp index 2342994c9..ec37b4105 100644 --- a/gtsam/slam/tests/testGeneralSFMFactor.cpp +++ b/gtsam/slam/tests/testGeneralSFMFactor.cpp @@ -50,7 +50,7 @@ class Graph: public NonlinearFactorGraph { public: void addMeasurement(int i, int j, const Point2& z, const SharedNoiseModel& model) { - push_back(std::make_shared(z, model, X(i), L(j))); + emplace_shared(z, model, X(i), L(j)); } void addCameraConstraint(int j, const GeneralCamera& p) { diff --git a/gtsam/slam/tests/testGeneralSFMFactor_Cal3Bundler.cpp b/gtsam/slam/tests/testGeneralSFMFactor_Cal3Bundler.cpp index f8385352f..3be35f793 100644 --- a/gtsam/slam/tests/testGeneralSFMFactor_Cal3Bundler.cpp +++ b/gtsam/slam/tests/testGeneralSFMFactor_Cal3Bundler.cpp @@ -51,7 +51,7 @@ class Graph: public NonlinearFactorGraph { public: void addMeasurement(const int& i, const int& j, const Point2& z, const SharedNoiseModel& model) { - push_back(std::make_shared(z, model, X(i), L(j))); + emplace_shared(z, model, X(i), L(j)); } void addCameraConstraint(int j, const GeneralCamera& p) { diff --git a/gtsam/symbolic/SymbolicBayesNet.h b/gtsam/symbolic/SymbolicBayesNet.h index f2c142762..bbfc968e1 100644 --- a/gtsam/symbolic/SymbolicBayesNet.h +++ b/gtsam/symbolic/SymbolicBayesNet.h @@ -69,7 +69,7 @@ namespace gtsam { /// Construct from a single conditional SymbolicBayesNet(SymbolicConditional&& c) { - push_back(std::make_shared(c)); + emplace_shared(c); } /** @@ -79,7 +79,7 @@ namespace gtsam { * SymbolicBayesNet(SymbolicConditional(...))(SymbolicConditional(...)); */ SymbolicBayesNet& operator()(SymbolicConditional&& c) { - push_back(std::make_shared(c)); + emplace_shared(c); return *this; } diff --git a/gtsam/symbolic/SymbolicFactorGraph.cpp b/gtsam/symbolic/SymbolicFactorGraph.cpp index ddcb3b2f3..1f17b8af2 100644 --- a/gtsam/symbolic/SymbolicFactorGraph.cpp +++ b/gtsam/symbolic/SymbolicFactorGraph.cpp @@ -40,22 +40,22 @@ namespace gtsam { /* ************************************************************************* */ void SymbolicFactorGraph::push_factor(Key key) { - push_back(std::make_shared(key)); + emplace_shared(key); } /* ************************************************************************* */ void SymbolicFactorGraph::push_factor(Key key1, Key key2) { - push_back(std::make_shared(key1,key2)); + emplace_shared(key1,key2); } /* ************************************************************************* */ void SymbolicFactorGraph::push_factor(Key key1, Key key2, Key key3) { - push_back(std::make_shared(key1,key2,key3)); + emplace_shared(key1,key2,key3); } /* ************************************************************************* */ void SymbolicFactorGraph::push_factor(Key key1, Key key2, Key key3, Key key4) { - push_back(std::make_shared(key1,key2,key3,key4)); + emplace_shared(key1,key2,key3,key4); } /* ************************************************************************* */ diff --git a/gtsam/symbolic/SymbolicFactorGraph.h b/gtsam/symbolic/SymbolicFactorGraph.h index 01b532a5c..fdd5bc27c 100644 --- a/gtsam/symbolic/SymbolicFactorGraph.h +++ b/gtsam/symbolic/SymbolicFactorGraph.h @@ -97,7 +97,7 @@ namespace gtsam { /// Construct from a single factor SymbolicFactorGraph(SymbolicFactor&& c) { - push_back(std::make_shared(c)); + emplace_shared(c); } /** @@ -107,7 +107,7 @@ namespace gtsam { * SymbolicFactorGraph(SymbolicFactor(...))(SymbolicFactor(...)); */ SymbolicFactorGraph& operator()(SymbolicFactor&& c) { - push_back(std::make_shared(c)); + emplace_shared(c); return *this; }