Topic: friend lookup


Author: Martin von Loewis <loewis@informatik.hu-berlin.de>
Date: 1999/09/13
Raw View
Martin Sebor <marts@att.net> writes:

> The problem is that 2 out of 4 major compilers I've tried this with fail
> to find the operator== in the template class and it's at least one of
> the compiler's vendor's position that due to 14.8.2.4, p4 (since the SS
> in S<int>::SS is a nested-name-specifier) the friend operator cannot be
> successfully looked up.

As usual, a number of alternatives are available:
- don't use these two major compilers that don't support your code, or
- change your code in a way that is accepted by all compilers. Most
  likely, not using nested classes will solve the problem.
- convince the vendors of the compilers rejecting your code that they
  are wrong. It appears that this approach has failed so far; you could
  go on exchanging arguments back and forth; or you could give up and
  use one of the other two options.

Not that this will help you, but I guess you are not looking for help
at this point.

Regards,
Martin
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Martin Sebor <marts@att.net>
Date: 1999/09/12
Raw View
Martin von Loewis wrote:
>
> sebor@my-deja.com writes:
>
> > I was just pointed to 14.8.2.4, p4 - it would seem that the arguments,
> > in fact, cannot be deduced, do you agree?
>
> No. What arguments cannot be deduced, in what context?
>
> According to 14.5.3/1, the operator== isn't even a template, it is a
> normal function declaration. Koenig lookup will find it, since the
> argument type is the class where the operator is declared. So what is
> the problem?
>

The problem is that 2 out of 4 major compilers I've tried this with fail
to find the operator== in the template class and it's at least one of
the compiler's vendor's position that due to 14.8.2.4, p4 (since the SS
in S<int>::SS is a nested-name-specifier) the friend operator cannot be
successfully looked up.

Martin


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Martin von Loewis <loewis@informatik.hu-berlin.de>
Date: 1999/09/10
Raw View
sebor@my-deja.com writes:

> I was just pointed to 14.8.2.4, p4 - it would seem that the arguments,
> in fact, cannot be deduced, do you agree?

No. What arguments cannot be deduced, in what context?

According to 14.5.3/1, the operator== isn't even a template, it is a
normal function declaration. Koenig lookup will find it, since the
argument type is the class where the operator is declared. So what is
the problem?

Regards,
Martin
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: sebor@my-deja.com
Date: 1999/09/09
Raw View
In article <p6q3dwp2m7z.fsf@informatik.hu-berlin.de>,
  Martin von Loewis <loewis@informatik.hu-berlin.de> wrote:
>
> sebor@my-deja.com writes:
>
> > Can anyone point me to the section in the Standard that makes this
> > [il]legal?
>
> It is legal, according to 7.3.1.2, [namespace.memdef]/3:
>
> # If a friend declaration in a non   local class first declares a class
> # or function the friend class or function is a member of the
> # innermost enclosing namespace. The name of the friend is not found
> # by simple name lookup until a matching declara   tion is provided in
> # that namespace scope (either before or after the class declaration
> # granting friendship). If a friend function is called, its name may
> # be found by the name lookup that considers functions from
> # name   spaces and classes associated with the types of the function
> # arguments (3.4.2).
>
> You probably need to have 14.5.3, [temp.friend]/3:
>
> # A friend template may be declared within a class or class
> # template. A friend function template may be defined within a class
> # or class template, but a friend class template may not be defined
> # in a class or class template.
>
> Hope this helps,
> Martin
>

I was just pointed to 14.8.2.4, p4 - it would seem that the arguments,
in fact, cannot be deduced, do you agree?

Martin


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Martin von Loewis <loewis@informatik.hu-berlin.de>
Date: 1999/09/08
Raw View
sebor@my-deja.com writes:

> Can anyone point me to the section in the Standard that makes this
> [il]legal?

It is legal, according to 7.3.1.2, [namespace.memdef]/3:

# If a friend declaration in a non   local class first declares a class
# or function the friend class or function is a member of the
# innermost enclosing namespace. The name of the friend is not found
# by simple name lookup until a matching declara   tion is provided in
# that namespace scope (either before or after the class declaration
# granting friendship). If a friend function is called, its name may
# be found by the name lookup that considers functions from
# name   spaces and classes associated with the types of the function
# arguments (3.4.2).

You probably need to have 14.5.3, [temp.friend]/3:

# A friend template may be declared within a class or class
# template. A friend function template may be defined within a class
# or class template, but a friend class template may not be defined
# in a class or class template.

Hope this helps,
Martin


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]