Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2005-03-30 04:59:41


> No I mean any idea about
>
> template<typename T>
> param_type
> {
> ....
> };
>
> Shouldn't we deprecate call traits if(once) we have corresponding traits
> in Traits_lib.

Or possibly deprecate param_type ;-)

On most modern machines the difference between passing small types by
reference and by value is negligible, the main use is to prevent aliasing
(similar to C99's restrict keyword):

void f(T& a, const T& b)
{
  while(condition)
  {
    // do something with b here
  }
}

In a situation like this b gets reloaded from memory with each pass through
the loop (because it may be aliased by a), whereas this does not occur with
pass-by-value, and even then you may be better off with just:

void f(T& a, const T& b)
{
  T t(b);
  while(condition)
  {
    // do something with t here
  }
}

or:

void f(T& a, const T& b)
{
  register typename some_heuistic<T>::type t(b);
  while(condition)
  {
    // do something with t here
  }
}

Where some_heuistic is specific to your algorithm, but is similar to
param_type.

If you still want param_type, then given that 90% plus of the code in
call_traits.hpp is there to implement param_type, why not just use
call_traits if that's what you want?

John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk