Skip to content

Commit

Permalink
Make operator-> const
Browse files Browse the repository at this point in the history
Having this operator non-const is awkward as operator* is const. This
sometimes leads to writing:
  (*obj).data; instead of obj->data;
which is unexpected....
  • Loading branch information
Sébastien Gonzalve committed Nov 10, 2024
1 parent a95d816 commit 733e919
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gtsam/nonlinear/Values.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace gtsam {
const_iterator_type it_;
deref_iterator(const_iterator_type it) : it_(it) {}
ConstKeyValuePair operator*() const { return {it_->first, *(it_->second)}; }
std::unique_ptr<ConstKeyValuePair> operator->() {
std::unique_ptr<ConstKeyValuePair> operator->() const {
return std::make_unique<ConstKeyValuePair>(it_->first, *(it_->second));
}
bool operator==(const deref_iterator& other) const {
Expand Down

0 comments on commit 733e919

Please sign in to comment.