Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2008-07-04 04:23:33


Michael Marcin wrote:
>> The documentation makes no mention of allowing extension for user
>> defined types. It in fact has a table which clearly states that
>> param_type is a const reference for all user defined types.
>>
>> In a specific case I was working on a 3d renderer that we used for a
>> mobile project where we used a templated fixed point class. There
>> were
>> some low level functions that worked on a typename Real which used
>> pass
>> by const reference because cheap copy was not a requirement of our
>> Real concept. This project happened to only be using this fixed
>> point type
>> which was a wrapper over int. We branched the code and changed the
>> functions to pass by value. This resulted in a measurable performance
>> increase.
>>
>> I would like to take classes like this and specialized param_type for
>> them but the documentation for this library doesn't seem to allow
>> for that.

There's nothing to stop you from adding a full or partial specialisation of
call_traits to your header:

struct my_value_type{ ... };

namespace boost{

template<>
struct call_traits<my_value_type>
{
  typedef my_value_type value_type;
  typedef my_value_type& reference;
  typedef my_value_type const& const_reference;
  typedef my_value_type param_type;
};

} // namespace

Then once your functions are call_traits aware, it's then easy to tweek
behaviour by adding specialisations as required.

Does this help?

John.


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