cppsks wrote:
> What would be the rational for using const with standard types?
>
> const int & OR const unsigned long &
Often a const reference to one of built-in types happens to be used
in template code, like
template <class T> void foo(T const& blah);
...
foo(42);
Nothing bad about it, AFAIK. I once did some testing and figured
that passing 'double' by value was just slightly slower than passing
it by a ref or by a pointer, but only in a debug version (or something
like that).
My rule is, "when in doubt, test". My other rule is, "for built-in
types, pass by value".
Victor
|