Simplify initializer list constructors.
parent
98f3c9676f
commit
b51f176232
|
@ -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
|
||||||
|
|
|
@ -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. */
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue