
7 Jul
2008
7 Jul
'08
3:43 p.m.
Philippe Vaucher wrote:
In general noone would write a function that took an int by const reference because doing so doesn't make sense from a performance standpoint. However often times we pass these trivial types to functions generically written to take const T&.
While I agree with it from a convenience-oriented point of view, I don't think using a reference is any slower than passing the POD by value. My point is that it'd not make a difference if sizeof(const T&) == sizeof(T). Does anyone knows of have some kind of benchmark showing passing an int by const ref is actually slower than by value?
As I mentioned in a previous post in this thread it really does have a measurable impact in some cases.