|
Boost : |
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2008-07-04 04:34:43
Philippe Vaucher skrev:
>> 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).
No, but it does make a difference if the compiler has to generate an
additional instruction for the indirection.
-Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk