Boost logo

Boost :

From: Alan Griffiths (alan_at_[hidden])
Date: 1999-12-20 10:25:05

In message <LPBBIIMJKJMPNOGHGLLCCEHGCBAA.gustav_at_[hidden]>,
Paul Moore <gustav_at_[hidden]> writes
>At the risk of exposing my ignorance, isn't that what Koenig lookup does for
>you? I assume that you are saying that a etc were std::vector and were changed
>to arg::vector. Doesn't Koenig lookup say that swap() is searched for in the
>namespace containing a's type - ie std:: or arg:: as appropriate?
>If that ISN'T what the lookup rules imply, then I agree with you.

If that were what the rule I wouldn't have an issue with them. :^)

However, there is a specific exclusion that means a class member is
matched without even considering argument dependent (Koenig) name

  (3.4.2 Argument-dependent name lookup - 2)
  . . .
  "If the ordinary unqualified lookup of the name finds the declaration
  of a class member function, the associated namespaces are not consid-

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

IMO it is far too late to change the meaning of existing code by
revising the name lookup rules.

>Regardless of the rights and wrongs, I'd have to say that this is all extremely
>subtle, and *not* the sort of stuff people could be expected to get right
>without better guidelines.

Agreed. However, it would be easy for me as a library implementer to
provide unsurprising behaviour if I could partially specialise the
standard swap algorithm to work correctly with my templates.

It is my role to understand this stuff, not Janet's or John's.

It is not too late to make previously invalid code valid, by allowing
partial specialisation (and overloading) within namespace std. (Given
suitable limits - can't change semantics, only on UDTs, ...)

Alan Griffiths  (alan_at_[hidden])
ACCU Chairman   (chair_at_[hidden])   

Boost list run by bdawes at, gregod at, cpdaniel at, john at