Topic: Defect? Qualified friends
Author: Martin von Loewis <loewis@informatik.hu-berlin.de>
Date: 1999/02/05 Raw View
Please consider the fragment
struct A{
struct B{};
};
A::B C();
namespace B{
A C();
}
class Test{
friend A ::B::C();
};
Is it correct? If so, what function is friend of Test?
I see three possible interpretations:
1) ::B::C is friend, with the production
simple-declaration
-> decl-specifier-seq init-declarator-list ;
-> FRIEND type-specifier declarator ;
-> FRIEND simple-type-specifier declarator-id () ;
-> FRIEND type-name qualified-id () ;
-> FRIEND A :: nested-name-specifier unqualified-id () ;
-> FRIEND A :: class-or-namespace-name :: C ();
-> FRIEND A ::B::C();
2) ::C is friend, with the production
simple-declaration
-> decl-specifier-seq init-declarator-list ;
-> FRIEND type-specifier declarator ;
-> FRIEND simple-type-specifier declarator-id () ;
-> FRIEND nested-name-specifier type-name unqualified-id () ;
-> FRIEND A::B C () ;
[missing production steps are left as an excercise :-)
3) The construct is ill-formed, it should be
friend A (::B::C)(); //or
friend A::B (::C)();
I couldn't find anything in the C++ standard ruling out any of those
interpretations.
Any comments appreciated,
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 ]