Quoth Oscar Lazzarino:
> Just guessing, but I don't think passing a boost::shared_ptr by const
> reference is a good idea. Just pass it by value.

Passing a boost::shared_ptr as a parameter by const reference is a *very*
good idea -- if you don't do this then you're needlessly copying it, and
copies are expensive (requires multiple interlocked operations).

It only becomes a potential concern in a multithreaded environment, and even
then only if you're mixing read/write operations on the same instance across
multiple threads (eg. from a member field).  But that's not special to
shared_ptr, most data structures will require additional locks if you're
doing that sort of thing.  And providing proper "get" methods that return
the shared_ptr by value (from within the appropriate lock) will mitigate
much of those sorts of problems too.


_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to