I'm using the code "boost::call_traits::param_type" on a win32 program@windows 7 machine. To my surprise, it's not "double" but "const double&".
I thought all primitive types are good to use "pass by value" for function parameters, isn't that a common sense? Because many people would use is_pod to determine using reference or not, isn't it?
That optimisation apparently only applies to "small" built-in types, according to the doc.
From a quick look at the source, it looks like "small" types are considered as those that satisfy sizeof(T) <= sizeof(void *)
. On a 32 bit machine this obviously doesn't include double
.
In some cases it may well be better to pass parameters as double
rather than double const&
, but as always, you'd have to benchmark and test...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With