From 2fd39fcecb47eebce727081c9ffb8edf86c33669 Mon Sep 17 00:00:00 2001 From: Sameer Agarwal Date: Thu, 1 Sep 2016 16:05:06 -0700 Subject: [PATCH] FindWithDefault returns by value rather than reference. Returning by reference leads to lifetime issues with the default value which may go out of scope by the time it is used. Thanks to @Ardavel for reporting this, as this causes graph_test to fail on VS2015x64. https://github.com/ceres-solver/ceres-solver/issues/216 Change-Id: I596481219cfbf7622d49a6511ea29193b82c8ba3 --- internal/ceres/map_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ceres/map_util.h b/internal/ceres/map_util.h index 61c531f29..f55aee376 100644 --- a/internal/ceres/map_util.h +++ b/internal/ceres/map_util.h @@ -67,7 +67,7 @@ FindOrDie(const Collection& collection, // If the key is present in the map then the value associated with that // key is returned, otherwise the value passed as a default is returned. template -const typename Collection::value_type::second_type& +const typename Collection::value_type::second_type FindWithDefault(const Collection& collection, const typename Collection::value_type::first_type& key, const typename Collection::value_type::second_type& value) {