Boost logo

Boost Users :

Subject: Re: [Boost-users] Covariant return type, method hiding, and shared_ptr advice
From: Nat Goodspeed (nat_at_[hidden])
Date: 2009-04-15 14:31:17


Dominique Devienne wrote:

> PS: is returning a const shared_ptr<T>& is better/worse than a copy?

My rule of thumb is: pass by const reference, return by value.

I keep having to change other people's code when a method is declared to
return const std::string&, and suddenly I need to return a string
expression rather than a reference to a data member. Even more irksome
is when that signature is declared on a virtual method. Then -- to
change the computation of one return value in one override -- I must run
around changing *every* signature.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net