From fa3a8103c5ea4069c55910cbcc0bd613d68d4b10 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Sun, 8 Jan 2023 21:21:44 -0800 Subject: [PATCH] Fix issues with gcc compiler. --- gtsam/base/FastList.h | 3 +++ gtsam/symbolic/tests/symbolicExampleGraphs.h | 5 +++-- .../symbolic/tests/testSymbolicBayesTree.cpp | 19 +++++++------------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gtsam/base/FastList.h b/gtsam/base/FastList.h index 47f813311..29ecd7dbc 100644 --- a/gtsam/base/FastList.h +++ b/gtsam/base/FastList.h @@ -56,6 +56,9 @@ public: /** Copy constructor from the base list class */ FastList(const Base& x) : Base(x) {} + /// Construct from c++11 initializer list: + FastList(std::initializer_list l) : Base(l) {} + #ifdef GTSAM_ALLOCATOR_BOOSTPOOL /** Copy constructor from a standard STL container */ FastList(const std::list& x) { diff --git a/gtsam/symbolic/tests/symbolicExampleGraphs.h b/gtsam/symbolic/tests/symbolicExampleGraphs.h index 2a9e71083..e3350dc5a 100644 --- a/gtsam/symbolic/tests/symbolicExampleGraphs.h +++ b/gtsam/symbolic/tests/symbolicExampleGraphs.h @@ -120,14 +120,15 @@ namespace gtsam { using sharedClique = SymbolicBayesTreeClique::shared_ptr; using Children = ListOf; - inline sharedClique LeafClique(const KeyVector& keys, + inline sharedClique LeafClique(const std::vector& keys, DenseIndex nrFrontals) { return boost::make_shared( boost::make_shared( SymbolicConditional::FromKeys(keys, nrFrontals))); } - inline sharedClique NodeClique(const KeyVector& keys, DenseIndex nrFrontals, + inline sharedClique NodeClique(const std::vector& keys, + DenseIndex nrFrontals, const std::vector& children) { sharedClique clique = LeafClique(keys, nrFrontals); clique->children.assign(children.begin(), children.end()); diff --git a/gtsam/symbolic/tests/testSymbolicBayesTree.cpp b/gtsam/symbolic/tests/testSymbolicBayesTree.cpp index 1d92404a8..c6daada1b 100644 --- a/gtsam/symbolic/tests/testSymbolicBayesTree.cpp +++ b/gtsam/symbolic/tests/testSymbolicBayesTree.cpp @@ -106,8 +106,7 @@ TEST(BayesTree, removePath) { SymbolicFactorGraph expected; expected.emplace_shared(_A_, _B_); expected.emplace_shared(_C_, _A_); - SymbolicBayesTree::Cliques expectedOrphans = - std::list{bayesTree[_D_], bayesTree[_E_]}; + SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_D_], bayesTree[_E_]}; SymbolicBayesNet bn; SymbolicBayesTree::Cliques orphans; @@ -123,8 +122,7 @@ TEST(BayesTree, removePath) { SymbolicFactorGraph expected2; expected2.emplace_shared(_A_, _B_); expected2.emplace_shared(_E_, _B_); - SymbolicBayesTree::Cliques expectedOrphans2 = - std::list{bayesTree[_F_], bayesTree[_C_]}; + SymbolicBayesTree::Cliques expectedOrphans2{bayesTree[_F_], bayesTree[_C_]}; SymbolicBayesNet bn2; SymbolicBayesTree::Cliques orphans2; @@ -149,8 +147,8 @@ TEST(BayesTree, removePath2) { SymbolicFactorGraph expected; expected.emplace_shared(_E_, _L_, _B_); CHECK(assert_equal(expected, factors)); - SymbolicBayesTree::Cliques expectedOrphans = - std::list{bayesTree[_S_], bayesTree[_T_], bayesTree[_X_]}; + SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_T_], + bayesTree[_X_]}; CHECK(assert_container_equal(expectedOrphans | indirected, orphans | indirected)); } @@ -170,8 +168,7 @@ TEST(BayesTree, removePath3) { expected.emplace_shared(_E_, _L_, _B_); expected.emplace_shared(_T_, _E_, _L_); CHECK(assert_equal(expected, factors)); - SymbolicBayesTree::Cliques expectedOrphans = - std::list{bayesTree[_S_], bayesTree[_X_]}; + SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_X_]}; CHECK(assert_container_equal(expectedOrphans | indirected, orphans | indirected)); } @@ -253,8 +250,7 @@ TEST(BayesTree, removeTop) { expected += SymbolicConditional::FromKeys(Keys(_S_)(_B_)(_L_), 1); CHECK(assert_equal(expected, bn)); - SymbolicBayesTree::Cliques expectedOrphans = - std::list{bayesTree[_T_], bayesTree[_X_]}; + SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_T_], bayesTree[_X_]}; CHECK(assert_container_equal(expectedOrphans | indirected, orphans | indirected)); @@ -291,8 +287,7 @@ TEST(BayesTree, removeTop2) { SymbolicConditional::FromKeys(Keys(_T_)(_E_)(_L_), 1)); CHECK(assert_equal(expected, bn)); - SymbolicBayesTree::Cliques expectedOrphans = - std::list{bayesTree[_S_], bayesTree[_X_]}; + SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_X_]}; CHECK(assert_container_equal(expectedOrphans | indirected, orphans | indirected)); }