This is the mail archive of the
egcs-bugs@egcs.cygnus.com
mailing list for the EGCS project.
Re: what is wrong here?
> > However, if that was the case: Why is it allowed that two using
> > declarations introduce two functions with identical parameter lists?
>
> This is just a guess: Maybe because functions can be overloaded, and
> there's no way fro a using declaration to select a subset of the
> declarations of an overloaded function.
That was a rhetorical question, sorry. A declaration of a friend
function is only a re-declaration if there was a prior declaration of
that function as a member of the enclosing namespace.
You seem to assume that a using-declaration makes the functions
denoted members of the namespace. If that was the case, then you would
get violations of the odr. So the logical consequence is that
using-declarations do not declare the functions as namespace members.
Otherwise, is the following text well-formed?
namespace A{void foo(){}}
namespace B{void foo(){}}
namespace C{using A::foo;using B::foo;class Bar{friend void foo();};}
My interpretation is: Yes, it is, but C::foo is not defined, yet.
> > namespace X{ void foo(); }
> > namespace Y{ using X::foo; class Bar{ friend void foo(){} }; }
>
> > Following your line of reasoning, this should define X::foo. I hope
> > this is not the case, though.
>
> According to my line of reasoning, this would be invalid because
> X::foo can only be defined in namespace X or in some enclosing
> namespace. However, I can't seem to find the restriction that a
> non-member function can only be defined in enclosing namepaces in the
> Standard at this very moment; am I mistaken?
It is in 7.3.1.2, [namespace.memdef]/2. However, this rule does not
strictly apply: the member is not defined by explicit qualification.
I still think that the original example
void foo();
namespace B{
using ::foo;
class X{
friend void foo();
int x;
};
}
void foo(){
X x;x.x=3;
}
is ill-formed in standard C++.
Regards,
Martin