diff --git a/gtsam_unstable/linear/ActiveSetSolver.h b/gtsam_unstable/linear/ActiveSetSolver.h index b96fcb6ba..e5f2d2d3a 100644 --- a/gtsam_unstable/linear/ActiveSetSolver.h +++ b/gtsam_unstable/linear/ActiveSetSolver.h @@ -99,8 +99,8 @@ protected: */ template Key maxKey(const PROBLEM& problem) { - Key maxKey = - *std::max_element(problem.cost.keys().begin(), problem.cost.keys().end()); + auto keys = problem.cost.keys(); + Key maxKey = *std::max_element(keys.begin(), keys.end()); if (!problem.equalities.empty()) maxKey = std::max(maxKey, *problem.equalities.keys().rbegin()); if (!problem.inequalities.empty())