is this standard C++?
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Tue Mar 14 00:20:00 GMT 2000
> This compiles with KCC and the DEC native compiler (cxx).
> But does not compile with g++ (2.95.2 or the feb28th snapshot)
> or with a beta version of IBM's xlC compiler. We can't
> find anything non-standard with it.
Thanks for your bug report. I was going to accept it as a bug, but I
think I found the relevant part of the standard that says your code is
ill-formed.
To make your example work, the compiler would need to deduce
T2=double, F2 = const_goo. 14.8.2.4/4 says that template type
arguments are not deduced in certain cases:
# The nondeduced contexts are: ...
# - A type that is a templateÃÂid in which one or more of the
# templateÃÂarguments is an expression that references a
# templateÃÂparameter.
In your case, const Foo<T2, FP2>& is a type that is a template-id, and
FP2 is an expression that references T2. So T2 is not deduced. It
would perhaps deduce FP2=const_goo, but that does not take it any
further; 14.8.2.4/11 says
# A template type argument cannot be deduced from the type of a
# nonÃÂtype templateÃÂargument.
If you question this line of reasoning, please discuss it in one of
the public C++ fora first, eg. comp.lang.c++.moderated, or
comp.std.c++.
Regards,
Martin
More information about the Gcc
mailing list