From 7034671315186344094
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,3b5faa9aaea18095
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-09-30 10:47:07 PST
Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: Patrick.Kowalzick@cern.ch ("Patrick Kowalzick")
Newsgroups: comp.std.c++
Subject: Re: Problem with function template overload resolution
Date: Tue, 30 Sep 2003 17:45:45 +0000 (UTC)
Organization: CERN
Lines: 59
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <blcbkh$k0u$1@sunnews.cern.ch>
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>
X-Trace: mail2news.demon.co.uk 1064943945 7554 10.0.0.1 (30 Sep 2003 17:45:45 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 30 Sep 2003 17:45:45 +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 1A4OZE-0001xg-00
	for mail2news@news.news.demon.net; Tue, 30 Sep 2003 17:45:44 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id DAA13084; Wed, 1 Oct 2003 03:45:40 +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-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
X-Spam-Status: No, hits=-5.4 required=5.0
	tests=BAYES_01,PRIORITY_NO_NAME,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++:7

Hello all,

> 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

I completely agree. Here we should read.

> 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.
>
> 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.

Here I do not agree. Part 2 says:

Given two overloaded function templates, wheter one is more specialized than
another can be determined by transforming each template in turn and using
argument deduction (14.8.2) to compare it to each other.

1. foo() is not overloaded
2. foo<U> is overloaded
3. foo<U1,U2> is not overloaded.

So I would use only case 2 which results in same specializaion level. So the
code could not be compiled.

Regards,
Patrick


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



