diff --git a/gtsam/config.h.in b/gtsam/config.h.in index 4b8bd180d..b480996ec 100644 --- a/gtsam/config.h.in +++ b/gtsam/config.h.in @@ -42,6 +42,9 @@ // Whether we are using TBB (if TBB was found and GTSAM_WITH_TBB is enabled in CMake) #cmakedefine GTSAM_USE_TBB +// Whether we are using a TBB version higher than 2020 +#cmakedefine TBB_GREATER_EQUAL_2020 + // Whether we are using system-Eigen or our own patched version #cmakedefine GTSAM_USE_SYSTEM_EIGEN diff --git a/gtsam/linear/VectorValues.h b/gtsam/linear/VectorValues.h index 5db4462e1..5de34c194 100644 --- a/gtsam/linear/VectorValues.h +++ b/gtsam/linear/VectorValues.h @@ -179,11 +179,12 @@ 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) { + template + inline std::pair emplace(Key j, Args&&... args) { #if ! defined(GTSAM_USE_TBB) || defined (TBB_GREATER_EQUAL_2020) - return values_.emplace(j, value); + return values_.emplace(j, std::forward(args)...); #else - return values_.insert(std::make_pair(j, value)); + return values_.insert(std::make_pair(j, Vector(std::forward(args)...))); #endif }