Some more emplace_shared instances prompted by code review.

release/4.3a0
Frank Dellaert 2023-02-06 10:55:39 -08:00
parent bf6f19e67e
commit 4eab29f714
8 changed files with 13 additions and 13 deletions

View File

@ -89,7 +89,7 @@ void HybridGaussianISAM::updateInternal(
// Add the orphaned subtrees // Add the orphaned subtrees
for (const sharedClique& orphan : *orphans) { for (const sharedClique& orphan : *orphans) {
factors.push_back(std::make_shared<BayesTreeOrphanWrapper<Node>>(orphan)); factors.emplace_shared<BayesTreeOrphanWrapper<Node>>(orphan);
} }
const VariableIndex index(factors); const VariableIndex index(factors);

View File

@ -41,7 +41,7 @@ void ISAM<BAYESTREE>::updateInternal(const FactorGraphType& newFactors,
// Add the orphaned subtrees // Add the orphaned subtrees
for (const sharedClique& orphan : *orphans) for (const sharedClique& orphan : *orphans)
factors.push_back(std::make_shared<BayesTreeOrphanWrapper<Clique> >(orphan)); factors.template emplace_shared<BayesTreeOrphanWrapper<Clique> >(orphan);
// Get an ordering where the new keys are eliminated last // Get an ordering where the new keys are eliminated last
const VariableIndex index(factors); const VariableIndex index(factors);

View File

@ -189,7 +189,7 @@ namespace gtsam {
template<typename T> template<typename T>
void addExpressionFactor(const SharedNoiseModel& R, const T& z, void addExpressionFactor(const SharedNoiseModel& R, const T& z,
const Expression<T>& h) { const Expression<T>& h) {
push_back(std::make_shared<ExpressionFactor<T> >(R, z, h)); this->emplace_shared<ExpressionFactor<T>>(R, z, h);
} }
/** /**

View File

@ -50,7 +50,7 @@ class Graph: public NonlinearFactorGraph {
public: public:
void addMeasurement(int i, int j, const Point2& z, void addMeasurement(int i, int j, const Point2& z,
const SharedNoiseModel& model) { const SharedNoiseModel& model) {
push_back(std::make_shared<Projection>(z, model, X(i), L(j))); emplace_shared<Projection>(z, model, X(i), L(j));
} }
void addCameraConstraint(int j, const GeneralCamera& p) { void addCameraConstraint(int j, const GeneralCamera& p) {

View File

@ -51,7 +51,7 @@ class Graph: public NonlinearFactorGraph {
public: public:
void addMeasurement(const int& i, const int& j, const Point2& z, void addMeasurement(const int& i, const int& j, const Point2& z,
const SharedNoiseModel& model) { const SharedNoiseModel& model) {
push_back(std::make_shared<Projection>(z, model, X(i), L(j))); emplace_shared<Projection>(z, model, X(i), L(j));
} }
void addCameraConstraint(int j, const GeneralCamera& p) { void addCameraConstraint(int j, const GeneralCamera& p) {

View File

@ -69,7 +69,7 @@ namespace gtsam {
/// Construct from a single conditional /// Construct from a single conditional
SymbolicBayesNet(SymbolicConditional&& c) { SymbolicBayesNet(SymbolicConditional&& c) {
push_back(std::make_shared<SymbolicConditional>(c)); emplace_shared<SymbolicConditional>(c);
} }
/** /**
@ -79,7 +79,7 @@ namespace gtsam {
* SymbolicBayesNet(SymbolicConditional(...))(SymbolicConditional(...)); * SymbolicBayesNet(SymbolicConditional(...))(SymbolicConditional(...));
*/ */
SymbolicBayesNet& operator()(SymbolicConditional&& c) { SymbolicBayesNet& operator()(SymbolicConditional&& c) {
push_back(std::make_shared<SymbolicConditional>(c)); emplace_shared<SymbolicConditional>(c);
return *this; return *this;
} }

View File

@ -40,22 +40,22 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
void SymbolicFactorGraph::push_factor(Key key) { void SymbolicFactorGraph::push_factor(Key key) {
push_back(std::make_shared<SymbolicFactor>(key)); emplace_shared<SymbolicFactor>(key);
} }
/* ************************************************************************* */ /* ************************************************************************* */
void SymbolicFactorGraph::push_factor(Key key1, Key key2) { void SymbolicFactorGraph::push_factor(Key key1, Key key2) {
push_back(std::make_shared<SymbolicFactor>(key1,key2)); emplace_shared<SymbolicFactor>(key1,key2);
} }
/* ************************************************************************* */ /* ************************************************************************* */
void SymbolicFactorGraph::push_factor(Key key1, Key key2, Key key3) { void SymbolicFactorGraph::push_factor(Key key1, Key key2, Key key3) {
push_back(std::make_shared<SymbolicFactor>(key1,key2,key3)); emplace_shared<SymbolicFactor>(key1,key2,key3);
} }
/* ************************************************************************* */ /* ************************************************************************* */
void SymbolicFactorGraph::push_factor(Key key1, Key key2, Key key3, Key key4) { void SymbolicFactorGraph::push_factor(Key key1, Key key2, Key key3, Key key4) {
push_back(std::make_shared<SymbolicFactor>(key1,key2,key3,key4)); emplace_shared<SymbolicFactor>(key1,key2,key3,key4);
} }
/* ************************************************************************* */ /* ************************************************************************* */

View File

@ -97,7 +97,7 @@ namespace gtsam {
/// Construct from a single factor /// Construct from a single factor
SymbolicFactorGraph(SymbolicFactor&& c) { SymbolicFactorGraph(SymbolicFactor&& c) {
push_back(std::make_shared<SymbolicFactor>(c)); emplace_shared<SymbolicFactor>(c);
} }
/** /**
@ -107,7 +107,7 @@ namespace gtsam {
* SymbolicFactorGraph(SymbolicFactor(...))(SymbolicFactor(...)); * SymbolicFactorGraph(SymbolicFactor(...))(SymbolicFactor(...));
*/ */
SymbolicFactorGraph& operator()(SymbolicFactor&& c) { SymbolicFactorGraph& operator()(SymbolicFactor&& c) {
push_back(std::make_shared<SymbolicFactor>(c)); emplace_shared<SymbolicFactor>(c);
return *this; return *this;
} }