To my knowledge, foo->bar()
is the same as (*foo).bar()
, except when the arrow is overloaded in a weird way, which usually should not be done. This answer seems to concur.
This however seems to not be true for boost::shared_ptrs. Above are two lines of my code that yield different results in some cases:
(*new_link).getRefNode() // returns some value
new_link->getRefNode() // returns something different...
What am I missing / not understanding here?
Edit: As requested, the cout code and what gets printed. I made sure that getRefNode() does not modify the instance in any way - if I change the order of the calls, the values change with the calls, so it's not about anything that getRefNode() does internally.
std::cout << "BLink1: " << (*previous_link).getId().toStdString()
<< ", ref: " << (*previous_link).getRefNode()
<< ", nref: " << (*previous_link).getNrefNode()
<< std::endl << "Link2: " << (*new_link).getId().toStdString()
<< ", ref: " << (*new_link).getRefNode()
<< ", nref: " << (*new_link).getNrefNode() << std::endl;
std::cout << "New link: " << new_link->getId().toStdString()
<< ", ref: " << new_link->getRefNode()
<< ", nref: " << new_link->getNrefNode() << std::endl;
BLink1: 1076889319, ref: (48.68674, 8.99122), nref: (48.68682, 8.99368)
Link2: 1076570435, ref: (48.68674, 8.99122), nref: (48.68682, 8.99368)
New link: 1076570435, ref: (48.68669, 8.98889), nref: (48.68674, 8.99122)
(Highlights by me)