Boost logo

Boost :

From: Alan Griffiths (alan_at_[hidden])
Date: 1999-12-22 16:45:40


In message <714DFA46B9BBD0119CD000805FC1F53BDC3961_at_UKRUX002.rundc.uk.ori
gin-it.com>, Moore, Paul <Paul.Moore_at_[hidden]> writes
>From: Alan Griffiths [mailto:alan_at_[hidden]]
[snip]
>> 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.)
>
>OK. I start to see what you are referring to. But aren't the signatures
>going to be different?
[snip]
>Oh, but is the problem that the compiler stops looking as soon as it finds a
>member version of abs() at class scope,

Yes, this is the problem that Janet resolved by a using definition
pulling the name from std. (Which was correct when she coded it, but
became _silently_ wrong as a result of a maintenance change by John.)

>even though the version it finds
>cannot match the call? Yuk. I was right - my brain does hurt.

Thanks for staying with me this far! Sorry not to have found a clearer
exposition - next time around. :)

>It looks to me like there is no even remotely obvious way of writing this
>stuff so that it works correctly in all cases.

For template members of std it is permitted to specialise the templates
on UDTs. For these cases the answer exists: provide a specialised
version of (for example) std::swap.

It even seems reasonable that a library developer should be able to
supply versions of the standard library functions that work correctly
with the elements provided by the library. (Surely this is the
motivation for allowing full specialisation?)

But one may not overload members of std, nor (as was pointed out
recently) partially specialise the very same members that can be fully
specialised. So this doesn't work for template libraries, or for
libraries that attempt to parallel the arithmetic types.

>I would be interested in
>getting the committee's comments on how all of this was meant to work. [Even
>if the comment was just "oops" :-)] Is there a way of formally requesting a
>rationale-style "how do I get this to work" comment? If so, I'd be willing
>to write up the scenario.

I don't think so. I believe defect reports are required to be
considered, but even then no response is required.

Informally, postings on comp.std.c++ seem as good an approach as any.

-- 
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