[Bug c++/25427] New: Impossible to create a friend function for a class in a namespace, outside the namespace.

2005-12-15 Thread sela_lerer at hotmail dot com
Can not create a friend function for a class that is in a namespace, if the
function is not in this namespace.

Example:

Command Line:
g++ -save-temps main.cpp

Error:
main.cpp:12: error: ‘std::ostream& operator<<(std::ostream&, S::A&)’ should
have been declared inside ‘::


-- 
   Summary: Impossible to create a friend function for a class in a
namespace, outside the namespace.
   Product: gcc
   Version: 4.0.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: sela_lerer at hotmail dot com
  GCC host triplet: i686-pc-Linux-gcc-c++-4.0.2-8.fc4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25427



[Bug c++/25427] Impossible to create a friend function for a class in a namespace, outside the namespace.

2005-12-15 Thread sela_lerer at hotmail dot com


--- Comment #1 from sela_lerer at hotmail dot com  2005-12-15 14:03 ---
Created an attachment (id=10494)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10494&action=view)
The source file that produced the error.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25427



[Bug c++/25427] Impossible to create a friend function for a class in a namespace, outside the namespace.

2005-12-15 Thread sela_lerer at hotmail dot com


--- Comment #2 from sela_lerer at hotmail dot com  2005-12-15 14:05 ---
Created an attachment (id=10495)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10495&action=view)
g++ preprocessed file.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25427



[Bug c++/25427] Impossible to create a friend function for a class in a namespace, outside the namespace.

2005-12-15 Thread sela_lerer at hotmail dot com


--- Comment #4 from sela_lerer at hotmail dot com  2005-12-15 16:36 ---
Ok, but what about an inner class? If A had a public inner class B and the
outer function had to operate on it?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25427



[Bug c++/25427] Impossible to create a friend function for a class in a namespace, outside the namespace.

2005-12-15 Thread sela_lerer at hotmail dot com


--- Comment #5 from sela_lerer at hotmail dot com  2005-12-15 16:38 ---
Ok, but what about an inner class? If A had a public inner class B and the
outer function had to operate on it?


-- 

sela_lerer at hotmail dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25427



[Bug c++/25427] Impossible to create a friend function for a class in a namespace, outside the namespace.

2005-12-16 Thread sela_lerer at hotmail dot com


--- Comment #7 from sela_lerer at hotmail dot com  2005-12-16 18:00 ---
(In reply to comment #6)
> (In reply to comment #5)
> > Ok, but what about an inner class? If A had a public inner class B and the
> > outer function had to operate on it?
> 
> 
> The code is still invalid.  Just there is no simple work around except split
> the class up like:
> namespace S
> {
>   class A {
>   class B;
>   methods 
> };
> }
> 
> function prototype to friend with;
> 
> class S::A::B
> {
>   friend function;
>   methods;
> };
> 
> function;
> 

hmmm.. ugly.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25427