mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
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
This commit is contained in:
@@ -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 <class Collection>
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user