From 5671039125210202544
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e7ce30bc16218953
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-01-07 20:27:11 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: gp1@paradise.net.nz (Graeme Prentice)
Newsgroups: comp.std.c++
Subject: Re: function template specialization deduction
Date: Wed, 8 Jan 2003 04:27:06 +0000 (UTC)
Lines: 69
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <5t8n1v8134h48gcmf2rir4s2po7alth29m@4ax.com>
References: <avf2t8$krl$1@sunsite.dk> <g2dm1vs0itq0ur51qi1m9lbjumoda8rd7b@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: mail2news.demon.co.uk 1042000026 14643 10.0.0.1 (8 Jan 2003 04:27:06 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 8 Jan 2003 04:27:06 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.05)
	id 18W7nz-0003o2-00
	for mail2news@news.news.demon.net; Wed, 08 Jan 2003 04:27:04 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id PAA18075; Wed, 8 Jan 2003 15:26:57 +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++@ncar.ucar.edu
X-Newsgroups: comp.std.c++
X-Orig-NNTP-Posting-Host: 203-96-149-214.apx1.paradise.net.nz (203.96.149.214)
X-Orig-X-Trace: fu-berlin.de 1041998843 16166200 203.96.149.214 (16 [98036])
X-Newsreader: Forte Agent 1.92/32.572
X-MailScanner: PASSED (v1.2.7 62724 h0847OfP076833 mailbox2.ucsd.edu)
X-Spam-Status: No, hits=-6.4 required=5.0
	tests=EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES,
	      SPAM_PHRASE_00_01
	version=2.41
Xref: archiver1.google.com comp.std.c++:16882

On Tue, 7 Jan 2003 18:55:11 +0000 (UTC), nesotto@cs.auc.dk ("THORSTEN
OTTOSEN") wrote:

[snip]

I think I'll have a third go at answering this since my first two
attempts were slightly wrong.

> My problem is then simply that cannot explain why
>the latter version is a better
>match than the first. I have tried looking at paragraph 13.3.3, 14.5.52 and
>14.8.3 but could not find anything
>that says that
>
>template< typename C, typename V >
> inline void insert( C& c, const V& );
>
>is a worse match than
>
> template< typename A >
> inline void
> insert( A& c, const typename A::container_type::value_type& v );
>
>Is there some rule that "fewer template parameters is better" ?

	
When the deduction process tries to call the second function with
arguments made up from the first, it has argument types of 
C& and const V&   -  C and V here are "made up"/synthesized types that
are unique  -  the std doesn't define precisely what is meant by unique
but the most obvious interpretation is that C and V are types that
appear nowhere else in the template parameter list or function parameter
list of either function.

Having made up the types C and V, the compiler tries to "call" the other
function  - for the first parameter, it can deduce the template
parameter A in the called function to be C  - for the second parameter
it can "plug in" C where A is and get 
const typename C::container_type::value_type &

from this, it is unable to determine the actual type of value_type to do
a comparison with V  - so deduction fails because it cannot determine
that value_type is the same type as V  -  but even if it could work out
the actual type of value_type,  it is guaranteed that it is not the same
type as V because V is a unique type that doesn't appear anywhere else.


Section 14.5.4.2 gives this example of "uniqueness" applying to non-type
parameters

template<int I, int J>
void f(X<I, J, int>);    // #A

template<int I> 
void f(X<I, I, int>);    // #B

14.5.4.2 says B is more specialized than A because when you make up
unique values for I and J in the first function, deduction into B fails
because of the template parameter I being deduced as two different
values.

Graeme

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



