Make Values::at return as const
parent
70b04afaa3
commit
32070b013f
|
|
@ -338,19 +338,18 @@ namespace gtsam {
|
||||||
} // internal
|
} // internal
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template<typename ValueType>
|
template <typename ValueType>
|
||||||
ValueType Values::at(Key j) const {
|
const ValueType Values::at(Key j) const {
|
||||||
// Find the item
|
// Find the item
|
||||||
KeyValueMap::const_iterator item = values_.find(j);
|
KeyValueMap::const_iterator item = values_.find(j);
|
||||||
|
|
||||||
// Throw exception if it does not exist
|
// Throw exception if it does not exist
|
||||||
if(item == values_.end())
|
if (item == values_.end()) throw ValuesKeyDoesNotExist("at", j);
|
||||||
throw ValuesKeyDoesNotExist("at", j);
|
|
||||||
|
|
||||||
// Check the type and throw exception if incorrect
|
// Check the type and throw exception if incorrect
|
||||||
// h() split in two lines to avoid internal compiler error (MSVC2017)
|
// h() split in two lines to avoid internal compiler error (MSVC2017)
|
||||||
auto h = internal::handle<ValueType>();
|
auto h = internal::handle<ValueType>();
|
||||||
return h(j,item->second);
|
return h(j, item->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
|
||||||
|
|
@ -187,8 +187,8 @@ namespace gtsam {
|
||||||
* Dynamic matrices/vectors can be retrieved as fixed-size, but not vice-versa.
|
* Dynamic matrices/vectors can be retrieved as fixed-size, but not vice-versa.
|
||||||
* @return The stored value
|
* @return The stored value
|
||||||
*/
|
*/
|
||||||
template<typename ValueType>
|
template <typename ValueType>
|
||||||
ValueType at(Key j) const;
|
const ValueType at(Key j) const;
|
||||||
|
|
||||||
/// version for double
|
/// version for double
|
||||||
double atDouble(size_t key) const { return at<double>(key);}
|
double atDouble(size_t key) const { return at<double>(key);}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue