This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/8568: Sutter's Befriending Templates troubles
- From: pcarlini at unitus dot it
- To: gcc-gnats at gcc dot gnu dot org
- Date: 13 Nov 2002 22:53:00 -0000
- Subject: c++/8568: Sutter's Befriending Templates troubles
- Reply-to: pcarlini at unitus dot it
>Number: 8568
>Category: c++
>Synopsis: Sutter's Befriending Templates troubles
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 13 14:56:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Paolo Carlini
>Release: 3.2.1 pre, 3.3 exp
>Organization:
>Environment:
Any.
>Description:
According to Herb Sutter:
http://www.cuj.com/experts/2101/sutter.htm
The following two testcases are legal and should compile:
// Example 1 again
//
namespace boost {
template<typename T> void checked_delete( T* x ) {
// ... other stuff ...
delete x;
}
}
class Test {
~Test() { }
friend void boost::checked_delete( Test* x ); // the original code
};
int main() {
boost::checked_delete( new Test );
}
///////////////////////////////
// Example 2: The other way to declare friendship
//
namespace boost {
template<typename T> void checked_delete( T* x ) {
// ... other stuff ...
delete x;
}
}
class Test {
~Test() { }
friend void boost::checked_delete<>( Test* x );
};
int main() {
boost::checked_delete( new Test );
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: