diff --git a/gtsam/linear/VectorValues.cpp b/gtsam/linear/VectorValues.cpp index eb92228e5..0a25617e4 100644 --- a/gtsam/linear/VectorValues.cpp +++ b/gtsam/linear/VectorValues.cpp @@ -96,16 +96,6 @@ namespace gtsam { return result.first; } - /* ************************************************************************* */ - std::pair VectorValues::emplace(Key j, const Vector& value) { -#ifdef TBB_GREATER_EQUAL_2020 - std::pair result = values_.emplace(j, value); -#else - std::pair result = values_.insert(std::make_pair(j, value)); -#endif - return result; - } - /* ************************************************************************* */ void VectorValues::update(const VectorValues& values) { diff --git a/gtsam/linear/VectorValues.h b/gtsam/linear/VectorValues.h index e11e98cce..5db4462e1 100644 --- a/gtsam/linear/VectorValues.h +++ b/gtsam/linear/VectorValues.h @@ -179,7 +179,13 @@ namespace gtsam { * j is already used. * @param value The vector to be inserted. * @param j The index with which the value will be associated. */ - std::pair emplace(Key j, const Vector& value); + std::pair emplace(Key j, const Vector& value) { +#if ! defined(GTSAM_USE_TBB) || defined (TBB_GREATER_EQUAL_2020) + return values_.emplace(j, value); +#else + return values_.insert(std::make_pair(j, value)); +#endif + } /** Insert a vector \c value with key \c j. Throws an invalid_argument exception if the key \c * j is already used. @@ -197,7 +203,7 @@ namespace gtsam { * and an iterator to the existing value is returned, along with 'false'. If the value did not * exist, it is inserted and an iterator pointing to the new element, along with 'true', is * returned. */ - std::pair tryInsert(Key j, const Vector& value) { + inline std::pair tryInsert(Key j, const Vector& value) { #ifdef TBB_GREATER_EQUAL_2020 return values_.emplace(j, value); #else diff --git a/gtsam/linear/linearAlgorithms-inst.h b/gtsam/linear/linearAlgorithms-inst.h index 57d26f5dc..e339347f1 100644 --- a/gtsam/linear/linearAlgorithms-inst.h +++ b/gtsam/linear/linearAlgorithms-inst.h @@ -103,7 +103,7 @@ namespace gtsam 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);