For boost::shared_ptr it's the same. Nothing is copied in both cases. Some
compilers might (which is under doubt) optimize it better. Since const is an
additional information for them, that the object is not going to change
within the called function.
const is definitely a benefit for you, since you can eliminate more errors
at compile time if you try to change the const object. I think a developer
should try to program as restrictive as possible, otherwise you might bring
unforeseen errors in your code. But that gets a bit philosophical.
On Thu, Mar 19, 2009 at 10:57 PM, anony
Igor R pravi:
Passing object by reference means you want to modify it inside the function. If you only want to avoid overhead, pass it by const reference.
Perhaps I do want to... Call reset() perhaps. Does boost::shared_ptr<> const& avoid overhead better than just boost::shared_ptr<T>&?