Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Template argument deduction fails on EDG - but why?

Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uwm.edu!rpi!not-for-mail
From: goo...@vandevoorde.com (Daveed Vandevoorde)
Newsgroups: comp.lang.c++.moderated
Subject: Re: Template argument deduction fails on EDG - but why?
Date: 15 May 2003 19:40:12 -0400
Organization: http://groups.google.com/
Lines: 51
Sender: cppm...@netlab.cs.rpi.edu
Approved: jep@[151.161.11.6]
Message-ID: <52f2f9cd.0305150921.2a8c0b85@posting.google.com>
References: <b9j9g9$bu9$1@news.tuwien.ac.at>
 <3ebe3da0@news.microsoft.com>
 <b9m242$rji$1@news.tuwien.ac.at>
 <3ebff6b4@news.microsoft.com>
NNTP-Posting-Host: netlab.cs.rpi.edu
X-Original-Date: 15 May 2003 10:21:43 -0700
X-Submission-Address: c++-sub...@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
	iQBVAwUAPsQlWUHMCo9UcraBAQFPcwH+I4kYrx+3Peemhm8c+eoBJJfptc0VXe3+
	L57UPu6lPp5JA9bBR0PQegzTJMUcIVXO6Gr5vRKge0ksoT39nybrtA==
	=hfYZ

"Rani Sharoni" <rani_shar...@hotmail.com> wrote:
> Stefan Slapeta wrote:
[...]
> > I think that's not really true, especially as there are strict rules
> > for type deduction in function template calls. Take a look at
> > [14.8.2.1] where it says:
> 
> I looked at 14.8.2 (especially 14.8.2.1/3) and I didn't see any
> treatment in
> the case (conversion) you presented. Notice that the following actually
> works (EDG and GCC):
> template<typename T> int test(T const&);
> 
> In this case T==int[10] and test<int[10]> is instantiated (per
> 14.8.2.1/3).
> 
> > There are no DRs on these lines, so I think EDG behaves incorrectly
> > here.
> 
> I'm really not authorized to say that but maybe Daveed Vandevoorde can
> help us with this issue.

OK.  Just work your way through 14.8.2.1.

Para 1: Our A is "int[10]" and our P is "T const(&)[S]".
Para 2:
   P is a reference type, so skip the 3 bullets.
   P is not a cv-qualified type (references never are),
     so skip the first sentence after the bullets.
   P is a reference type, so we use P' = "T const [S]"
     for deduction purposes.
Para 3:
   We try to find T, S such that P' becomes identical
   to A.  That's not possible, so we looks at the
   three bullets.  The 2nd and 3rd don't apply, but
   the first implies that T=int, S=10 is OK because
   "int const[10]" is more cv-qualified that "int[10]"
   (see 3.9/5).

So deduction succeeds.  Now you've got to check that
the resulting specialization is viable (it is; left
as an exercise to the reader <grin>), and selected
by overload resolution (trivial; there is but one
viable candidate).

So yes, this is valid code and an EDG bug (known).

        Daveed

      [ Send an empty e-mail to c++-h...@netlab.cs.rpi.edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]