Re: efficiency in passing a value to a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sunday, 8 April 2007 17:17, Shriramana Sharma wrote:

> I agree of course that in case of tiny tidbits of parameters like a few
> int-s, double-s or even std::string-s, there is not much meaning in
> using const ref-s, and it is more intuitive to pass these by value. It
> is only practically useful to pass big classes / struct-s by reference.

Well, std::string should be passed by const reference. Depending on the 
implementation, passing std::string by value may involve heap 
allocation/deallocation and memory copy operations which are quite costly.

Adam

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux