Message from discussion Template argument deduction fails on EDG - but why?
From: goo...@vandevoorde.com (Daveed Vandevoorde)
Subject: Re: Template argument deduction fails on EDG - but why?
Date: 15 May 2003 19:40:12 -0400
X-Original-Date: 15 May 2003 10:21:43 -0700
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
"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
> > [220.127.116.11] where it says:
> I looked at 14.8.2 (especially 18.104.22.168/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 and test<int> is instantiated (per
> > 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 22.214.171.124.
Para 1: Our A is "int" and our P is "T const(&)[S]".
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.
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" is more cv-qualified that "int"
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
So yes, this is valid code and an EDG bug (known).
[ Send an empty e-mail to c++-h...@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]