[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: G++-3.x bug? user specified operator== not found/used by find

On Mon, Jun 17, 2002 at 04:37:11PM +0200, Christof Petig wrote:
> Christof Petig wrote:
> > The following code does not compile with g++-3.0 and g++-3.1, but it 
> > does with g++-2.95.4. What is wrong (std:: is not missing!)?
> Oh, std:: was missing - in a way ...
> std::find only looks in namespace std:: for an operator==, if I specify 
> it inside namespace std { ... } , it works.

Welcome to Koenig lookup.

> Gives me a strange feeling though to declare user supplied operators in std.

It's explicitly permitted to declare certain things in std, as long as

    a) you are specializing an existing template, not adding new names, and
    b) the specialization involves at least one of your own types

> Perhaps the namepace of the first argument determines the namespace 
> searched for the operator ?

No, not exactly, but namespaces containing the declaration of the argument
type(s) are searched.

I recommend finding a good C++ text and reading about "argument-dependant
name lookup," aka Koenig lookup.


If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams

To UNSUBSCRIBE, email to debian-gcc-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: