Boost logo

Boost :

From: Alan Griffiths (alan_at_[hidden])
Date: 1999-12-21 14:56:46


In message <714DFA46B9BBD0119CD000805FC1F53BDC395F_at_UKRUX002.rundc.uk.ori
gin-it.com>, Moore, Paul <Paul.Moore_at_[hidden]> writes
>From: Alan Griffiths [mailto:alan_at_[hidden]]
>> Moore, Paul <Paul.Moore_at_[hidden]> writes
[snip]
>> > But I'm working on the basis that Janet's code above, even without
>> > the using std::swap, works whatever namespace a is in.
>>
>> Because of the above Janet has to explicitly pull std::swap into the
>> current scope. (Otherwise only C::swap is considered.)
>
>Ah. I'd missed the fact that we had moved on from abs() (which is not a
>member) to swap (which is, or is implemented in terms of one).

Sorry, I'd not moved on, but you happened to respond to the swap fibre.

>Ignore me :-)

No, the point still holds...

    arg::vector => boost::rational
    std::swap => std::abs
    client::swap(C&, C&) => client::abs(const C&)
    client::C& C::swap(C&) => boost::rational<int> C::abs() const

The difficulty I foresee is that there is no way of stopping the client
code existing inside a class that has an abs/swap member. (OK, I admit
that implementing abs by forwarding to C::abs is less likely than the
equivalent swap scenario.)

Getting the name lookup to work in an unsurprising manner in such cases
has exactly the same set of problems as the swap example. (Especially
as the parts of this scenario could be put in place over a period of
time, in different classes, by different maintainers.)

-- 
Alan Griffiths  (alan_at_[hidden])  http://www.octopull.demon.co.uk/
ACCU Chairman   (chair_at_[hidden])             http://www.accu.org/

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