From -4894660925300360803
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ab08a3e89d74b8d7
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-05-09 20:04:02 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Hyman Rosen <hyrosen@mail.com>
Newsgroups: comp.std.c++
Subject: Re: Core Language Active Issue #329
Date: Fri, 10 May 2002 03:03:04 GMT
Organization: KBC Financial Products
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <3CD99A77.2040301@mail.com>
References: <3CD19D55.1050804@mail.com> <x9PA8.1887$9W4.932959@news6-win.server.ntlworld.com> <3CD6A00D.2080502@mail.com> <o5dC8.499$1r.48797@news8-gui.server.ntli.net>
X-Trace: mail2news.demon.co.uk 1020999790 mail2news:13507 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0rc1) Gecko/20020417
X-Accept-Language: en-us, en
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com
X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)
Lines: 56
Xref: archiver1.google.com comp.std.c++:11132

Garry Lancaster wrote:
> Hyman Rosen:
>>The declaration itself can involve the template
>>parameters in such a way that it is legal for some
>>types and illegal for others.
> 
> Could you explain what you mean by that?

Simple enough -

template<typename T>
struct X
{
	friend void f(typename T::t) { }
};

Whenever you instantiate an X<T>, you have to inject
void f(T::t) into the enclosing namespace. Whether
you inject the declaration or the definition, it's
stiil going to be illegal if the T in question doesn't
have a member type t.

> Perhaps you could give some reasons why the behaviour
> should remain as currently specified?

There's the issue of what happens when two instantiations
cause an ODR violation:

template <int N> struct X { friend int f() { return N; } };
X<1> x1; X<2> x2;

Would this be an error? (It is now.)

You could also break existing programs:

file1.cpp:
template <typename T> struct X { friend void f(T) { }; };
X<int> x;

file2.cpp:
extern void f(int);
int main() { f(3); }

This would fail to link, whereas it would work currently.

Finally, 14.5.3/5 is crystal clear in its description of what
happens when templates define friend functions. I understood
that the issues list was to resolve defects and ambiguities
in the standard, not to change the language.

---
[ 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                       ]



