Boost logo

Boost :

From: Kevlin Henney (Kevlin.Henney_at_[hidden])
Date: 2000-01-11 09:25:55

John Maddock wrote:
>Dicission Making: What is the optimal way to pass T as an argument - as
>const T (by value) or const T& (by reference) - in other words to

Just been thinking about the call_traits idea, and I'm a little unsure of
it. For instance, "optimal" depends heavily on platform, algorithm, etc.
Which suggests a lot of preprocessor conditionals to do the idea justice.

However, I think the real problem I'm having with it lies in the fact that
passing by const T and passing by const T& are not equivalent, so hiding
the difference can lead to subtle pitfalls: Aliasing can easily come back
to bite you: an algorithm can remove something from a container that
invalidates the reference but not the copy. This would mean that the
correctness of an algorithm could depend on properties of the data type and
platform that had nothing to do with the algorithm's requirements.



Boost list run by bdawes at, gregod at, cpdaniel at, john at