From -2859815798327715594
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,da46f9d6feb862e5
X-Google-Attributes: gidf78e5,public
From: hinnant@_anti-spam_metrowerks.com (Howard Hinnant)
Subject: Re: Is this well-formed?
Date: 1999/04/21
Message-ID: <hinnant-1904991720120001@ith3-285.twcny.rr.com>#1/1
X-Deja-AN: 469063384
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <7f1nnv$6c$1@weber.techno-link.com> <7ffmrv$j09$1@nnrp1.dejanews.com>
X-Original-Date: Mon, 19 Apr 1999 17:20:12 -0400
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 924684865 16890 128.250.29.16 (21 Apr 1999 08:54:25 GMT)
Organization: Metrowerks
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANx2SK+EDnX0m9pzZAQFRMAF/fTyvxM8iTg9lPa+GRKHkhNv5+Wd6s4hh uLnBq7KvkOmxvmCensV2gm6/zQ0nY0kG =zWhh
NNTP-Posting-Date: 21 Apr 1999 08:54:25 GMT
Newsgroups: comp.std.c++

In article <7ffmrv$j09$1@nnrp1.dejanews.com>,
James.Kanze@dresdner-bank.com wrote:

> $1@weber.techno-link.com>,
>   "Peter Dimov" <pdimov@techno-link.com> wrote:
> > Is the following program well-formed?
> >
> > template<class U> void f(U*)
> > {
> > }
> >
> > void f(int*)
> > {
> > }
> >
> > int main()
> > {
> >  f(0);
> >  return 0;
> > }

> According to 13.3.3., a non-template function is a better match than a
> template function, so the non template f(int*) should be preferred.  I
> suspect that Microsoft is trying to instantiate the template in order to
> create the list of all viable functions, and failing, because there are
> an infinite number of instantiations which could work.
> 
> I don't think Microsoft is the only compiler to have this error.  If you
> think about it, it isn't simple; if an instantiation of the template
> were to give f(int), this would be preferred over the non-template
> function.  (I also have vague memories that at one time, if a
> non-template function could be called, template functions weren't even
> considered.  But I could be wrong about that.)

Metrowerks CodeWarrior gets it right and runs on Windows.

-Howard
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]



