From -2969505258625474083
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,3b5faa9aaea18095
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-09-30 22:50:46 PST
Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: jhrwalter@yahoo.com (Joerg Walter)
Newsgroups: comp.std.c++
Subject: Re: Problem with function template overload resolution
Date: Wed, 1 Oct 2003 05:50:43 +0000 (UTC)
Organization: http://groups.google.com
Lines: 65
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <4e6fccc6.0309301317.7a4d3d00@posting.google.com>
References: <4e6fccc6.0309162227.1aa4bda7@posting.google.com> <3F6E975F.8050300@grad.hr> <bkos2l$8t1$1@sunnews.cern.ch> <4e6fccc6.0309231302.4c6a4a9f@posting.google.com> <fur9nvsta83c5et8drf2amoqhhs1lvoqu5@4ax.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: mail2news.demon.co.uk 1064987443 11335 10.0.0.1 (1 Oct 2003 05:50:43 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 1 Oct 2003 05:50:43 +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 1A4Zso-0002wf-00
	for mail2news@news.news.demon.net; Wed, 01 Oct 2003 05:50:42 +0000
X-Received: by mulga.cs.mu.OZ.AU
	id PAA27046; Wed, 1 Oct 2003 15:50:32 +1000 (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-NNTP-Posting-Date: Tue, 30 Sep 2003 21:17:00 +0000 (UTC)
X-Spam-Status: No, hits=-3.1 required=5.0
	tests=BAYES_01,FORGED_YAHOO_RCVD,QUOTED_EMAIL_TEXT,REFERENCES
	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++:10

gp1@paradise.net.nz (Graeme Prentice) wrote in message news:<fur9nvsta83c5et8drf2amoqhhs1lvoqu5@4ax.com>...
> On Wed, 24 Sep 2003 15:23:13 +0000 (UTC), jhrwalter@yahoo.com (Joerg
> Walter) wrote:
> 
> >
> >We're not talking about partial specializations but about the interference
> >of explicit specification with argument deduction as far as I understand
> >14.1.8 bullet 2:
> >
> >----------
> >Trailing template arguments that can be deduced (14.8.2) may be omitted from
> >the list of explicit template-arguments. ...
> >----------
> 
> This rule means both functions are callable.  The two functions are
> overloads of each other.  The compiler uses the partial ordering rules
> to determine if one function is more specialised than the other
> 14.5.5.2 para 1 to 5

OK.

> Partial ordering applied to these two functions works like this ...
> 
> template<typename A>
> result<A, typename A::value_type> foo(A const& a) {
>    std::cout << "foo<A>" << std::endl;
>    return result<A, typename A::value_type>();
> }
> 
> template<typename R, typename A>
> R foo(A const& a) {
>    std::cout << "foo<R, A>" << std::endl;
>    return R();
> }
> 
> 
> For the first foo(), synthesize a unique type U for the template type
> parameter A and call the second foo  i.e. the call is foo( abc ) where
> abc is U const &.  For this call, the compiler is unable to deduce the
> type of the template parameter R so deduction fails.

I see.

> Now this is done in reverse  - for the second foo(), synthesize unique
> types U1, U2 for R and A and call the first foo()  - the call is
> foo(abc) where abc has type U1 const &.  Deduction succeeds because the
> template parameter A of the first function is deduced as U1.  Hence the
> second foo is more specialised than the first (para 4 & 5)  so the call
> foo<arg2<int> >(s2); is not ambiguous.

I see, too.

[...]

Thanks a lot for your explanation,
Joerg

P.S.: but this resolution is still surprising ;-)

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



