Make Values::at return as const

release/4.3a0
Varun Agrawal 2020-11-19 13:42:52 -05:00
parent 70b04afaa3
commit 32070b013f
2 changed files with 9 additions and 10 deletions

View File

@ -339,13 +339,12 @@ namespace gtsam {
/* ************************************************************************* */
template <typename ValueType>
ValueType Values::at(Key j) const {
const ValueType Values::at(Key j) const {
// Find the item
KeyValueMap::const_iterator item = values_.find(j);
// Throw exception if it does not exist
if(item == values_.end())
throw ValuesKeyDoesNotExist("at", j);
if (item == values_.end()) throw ValuesKeyDoesNotExist("at", j);
// Check the type and throw exception if incorrect
// h() split in two lines to avoid internal compiler error (MSVC2017)

View File

@ -188,7 +188,7 @@ namespace gtsam {
* @return The stored value
*/
template <typename ValueType>
ValueType at(Key j) const;
const ValueType at(Key j) const;
/// version for double
double atDouble(size_t key) const { return at<double>(key);}