Add initializer list constructors

release/4.3a0
Frank Dellaert 2023-01-07 19:25:34 -08:00
parent f9ccf111d1
commit 6cbd7c286c
2 changed files with 19 additions and 0 deletions

View File

@ -60,6 +60,16 @@ namespace gtsam {
explicit SymbolicBayesNet(const FactorGraph<DERIVEDCONDITIONAL>& graph)
: Base(graph) {}
/**
* Constructor that takes an initializer list of shared pointers.
* FactorGraph fg = {make_shared<MyFactor>(), ...};
*/
SymbolicBayesNet(
std::initializer_list<boost::shared_ptr<SymbolicConditional>>
sharedFactors) {
for (auto&& f : sharedFactors) factors_.push_back(f);
}
/// Destructor
virtual ~SymbolicBayesNet() {}

View File

@ -81,6 +81,15 @@ namespace gtsam {
template<class DERIVEDFACTOR>
SymbolicFactorGraph(const FactorGraph<DERIVEDFACTOR>& graph) : Base(graph) {}
/**
* Constructor that takes an initializer list of shared pointers.
* FactorGraph fg = {make_shared<MyFactor>(), ...};
*/
SymbolicFactorGraph(std::initializer_list<boost::shared_ptr<SymbolicFactor>>
sharedFactors) {
for (auto&& f : sharedFactors) factors_.push_back(f);
}
/// Destructor
virtual ~SymbolicFactorGraph() {}