Simplify initializer list constructors.

release/4.3a0
Frank Dellaert 2023-01-09 22:43:14 -08:00
parent 98f3c9676f
commit b51f176232
4 changed files with 9 additions and 18 deletions

View File

@ -166,10 +166,8 @@ class FactorGraph {
* FactorGraph fg = {make_shared<MyFactor>(), ...}; * FactorGraph fg = {make_shared<MyFactor>(), ...};
*/ */
template <class DERIVEDFACTOR, typename = IsDerived<DERIVEDFACTOR>> template <class DERIVEDFACTOR, typename = IsDerived<DERIVEDFACTOR>>
FactorGraph( FactorGraph(std::initializer_list<boost::shared_ptr<DERIVEDFACTOR>> sharedFactors)
std::initializer_list<boost::shared_ptr<DERIVEDFACTOR>> sharedFactors) { : factors_(sharedFactors) {}
for (auto&& f : sharedFactors) factors_.push_back(f);
}
/// @} /// @}
/// @name Adding Single Factors /// @name Adding Single Factors

View File

@ -92,11 +92,8 @@ namespace gtsam {
VectorValues() {} VectorValues() {}
/// Construct from initializer list. /// Construct from initializer list.
VectorValues(std::initializer_list<std::pair<Key, Vector>> init) { VectorValues(std::initializer_list<std::pair<Key, Vector>> init)
for (const auto& p : init) { : values_(init.begin(), init.end()) {}
values_.insert(p); // Insert key-value pair into map
}
}
/** Merge two VectorValues into one, this is more efficient than inserting /** Merge two VectorValues into one, this is more efficient than inserting
* elements one by one. */ * elements one by one. */

View File

@ -64,11 +64,8 @@ namespace gtsam {
* Constructor that takes an initializer list of shared pointers. * Constructor that takes an initializer list of shared pointers.
* FactorGraph fg = {make_shared<MyFactor>(), ...}; * FactorGraph fg = {make_shared<MyFactor>(), ...};
*/ */
SymbolicBayesNet( SymbolicBayesNet(std::initializer_list<boost::shared_ptr<SymbolicConditional>> sharedFactors)
std::initializer_list<boost::shared_ptr<SymbolicConditional>> : Base() {}
sharedFactors) {
for (auto&& f : sharedFactors) factors_.push_back(f);
}
/// Construct from a single conditional /// Construct from a single conditional
SymbolicBayesNet(SymbolicConditional&& c) { SymbolicBayesNet(SymbolicConditional&& c) {

View File

@ -91,10 +91,9 @@ namespace gtsam {
* Constructor that takes an initializer list of shared pointers. * Constructor that takes an initializer list of shared pointers.
* FactorGraph fg = {make_shared<MyFactor>(), ...}; * FactorGraph fg = {make_shared<MyFactor>(), ...};
*/ */
SymbolicFactorGraph(std::initializer_list<boost::shared_ptr<SymbolicFactor>> SymbolicFactorGraph(
sharedFactors) { std::initializer_list<boost::shared_ptr<SymbolicFactor>> sharedFactors)
for (auto&& f : sharedFactors) factors_.push_back(f); : Base(sharedFactors) {}
}
/// Construct from a single factor /// Construct from a single factor
SymbolicFactorGraph(SymbolicFactor&& c) { SymbolicFactorGraph(SymbolicFactor&& c) {