Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-08-30 06:15:12


>> I can't use call_traits; using call_traits changes the semantics of the
>>call
>> thanks to that wonderful invention called std::auto_ptr. ;-) The
interface
>> should not specify optimizations, only behavior.
>
>This can be easily fixed if call_traits were to be partially specialised
>for auto_ptr to use pass by value. That's probably not a bad idea.

auto_ptr is a tricky case, making call_traits<auto_ptr<T> >::param_type do
pass by value would have unexpected consequences if it were used in a
situation were call-by-reference semantics are expected and call_traits has
been used as a possible optimisation. In other words call_traits should do
call-by-value only if:

1) It has the same semantics as call-by-ref
2) It is no less efficient than call-by-ref

auto_ptr fails on #1.

I guess one possible solution would be to have:

call_traits<auto_ptr<T> >::param_type

evaluate as a non-const ref:

auto_ptr<T>&

Would that keep everyone happy, and allow some progress to be made? Mark?
Peter?

- John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/


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