Fixed emplace to align with std
parent
1fe876aba6
commit
5bf8dc4174
|
@ -97,17 +97,13 @@ namespace gtsam {
|
|||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
VectorValues::iterator VectorValues::emplace(Key j, const Vector& value) {
|
||||
std::pair<VectorValues::iterator, bool> VectorValues::emplace(Key j, const Vector& value) {
|
||||
#ifdef TBB_GREATER_EQUAL_2020
|
||||
std::pair<iterator, bool> result = values_.emplace(j, value);
|
||||
#else
|
||||
std::pair<iterator, bool> result = values_.insert(std::make_pair(j, value));
|
||||
#endif
|
||||
if(!result.second)
|
||||
throw std::invalid_argument(
|
||||
"Requested to emplace variable '" + DefaultKeyFormatter(j)
|
||||
+ "' already in this VectorValues.");
|
||||
return result.first;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace gtsam {
|
|||
* j is already used.
|
||||
* @param value The vector to be inserted.
|
||||
* @param j The index with which the value will be associated. */
|
||||
iterator emplace(Key j, const Vector& value);
|
||||
std::pair<VectorValues::iterator, bool> emplace(Key j, const Vector& value);
|
||||
|
||||
/** Insert a vector \c value with key \c j. Throws an invalid_argument exception if the key \c
|
||||
* j is already used.
|
||||
|
|
|
@ -98,8 +98,13 @@ namespace gtsam
|
|||
// Insert solution into a VectorValues
|
||||
DenseIndex vectorPosition = 0;
|
||||
for(GaussianConditional::const_iterator frontal = c.beginFrontals(); frontal != c.endFrontals(); ++frontal) {
|
||||
VectorValues::const_iterator r =
|
||||
collectedResult.emplace(*frontal, solution.segment(vectorPosition, c.getDim(frontal)));
|
||||
auto result = collectedResult.emplace(*frontal, solution.segment(vectorPosition, c.getDim(frontal)));
|
||||
if(!result.second)
|
||||
throw std::invalid_argument(
|
||||
"Requested to emplace variable '" + DefaultKeyFormatter(*frontal)
|
||||
+ "' already in this VectorValues.");
|
||||
|
||||
VectorValues::const_iterator r = result.first;
|
||||
myData.cliqueResults.emplace(r->first, r);
|
||||
vectorPosition += c.getDim(frontal);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue