?// here is the data I just got that was at the front
http://bytes.com/groups/cpp/163953-pass-reference-vs-pass-pointer
> Aside from the NULL PTR safety of the reference version, is there a
> performance advantage in the way the function and parameters are
> placed/copied onto the stack for either version?
No, but I can imagine the reference version to be easier to optimize (because
no analysis is needed to check what the reference refers to in each
statement), so it might be that it's better optimized with some compilers.
However, the NULL pointer safety is important, and there are other
non-efficiency related issues.
One particularly important such issue is that the reference cannot be
re-seated within the function. Another is that arithmetic cannot be performed
on the reference, only on the object it refers to (think of e.g. a std::string
argument). A third is that the reference signature clearly indicates a single
object, whereas the pointer signature matches object or array or null.
No comments:
Post a Comment