From 3081721528964731543
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,cbf1693e6ece180b,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-12-12 19:16:22 PST
Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!newspeer1.nwr.nac.net!colt.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: cpdaniel_remove_this_and_nospam@mvps.org.nospam ("Carl Daniel")
Newsgroups: comp.std.c++
Subject: template friends
Date: Sat, 13 Dec 2003 03:16:18 +0000 (UTC)
Organization: SBC http://yahoo.sbc.com
Lines: 55
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <4MpCb.70557$Qn2.26313@newssvr25.news.prodigy.com>
X-Trace: mail2news.demon.co.uk 1071285378 19878 10.0.0.1 (13 Dec 2003 03:16:18 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sat, 13 Dec 2003 03:16:18 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 1AV0GO-0005AT-00
	for mail2news@news.news.demon.net; Sat, 13 Dec 2003 03:16:16 +0000
X-Received: by mulga.cs.mu.OZ.AU
	id OAA27870; Sat, 13 Dec 2003 14:16:13 +1100 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Newsgroups: comp.std.c++
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-NNTP-Posting-Date: Fri, 12 Dec 2003 15:43:44 EST
X-UserInfo1: [[PA@SJEERV[BFH[OZK@_TDAYZOZ@GXOXR]ZMVMHQAVTUZ]CLNTCPFK[WDXDHV[K^FCGJCJLPF_D_NCC@FUG^Q\DINVAXSLIFXYJSSCCALP@PB@\OS@BITWAH\CQZKJMMD^SJA^NXA\GVLSRBD^M_NW_F[YLVTWIGAXAQBOATKBBQRXECDFDMQ\DZFUE@\JM
X-Spam-Status: No, hits=-3.8 required=5.0
	tests=BAYES_01,HTML_10_20,PRIORITY_NO_NAME
	version=2.55
X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
Xref: archiver1.google.com comp.std.c++:675

Consider the following code:

// <code>
template <class T> class C;

template <class T1, class T2> T1 f(const C<T2>&); // 1
template <class T> T f(const C<T>&); // 2

template <class T> class C
{
  private:  T m_t;

  friend T f<T,T>(const C&); // a
  friend T f<T>(const C&);   // b
  friend T f<>(const C&);    // c
};

template <class T>
T f(const C<T>& ct)
{
  return ct.m_t;
}

template <class T1, class T2>
T1 f(const C<T2>& ct)
{
  return ct.m_t;
}

void test()
{
   C<int> ci;
   f<int>(ci);
   f<int,int>(ci);
}

// </code>

According to Comeau online, any of the three friend declarations (a/b/c)
grants friendship to both template functions (1/2).

I would intuitively expect that 'a' should grant friendship to '1', 'b'
should grant friendship to '2' and 'c' should grant friendship to both '1'
and '2'.

Is Comeau right?  (It usually is!)

-cd

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]



