This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [C++] float, double & complex template non-type parms
- To: fjh at cs dot mu dot oz dot au
- Subject: Re: [C++] float, double & complex template non-type parms
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Mon, 26 Feb 2001 13:23:57 -0800
- Cc: nathan at codesourcery dot com, gcc at gcc dot gnu dot org, jason at redhat dot com
- Organization: CodeSourcery, LLC
- References: <20010227015158.A17208@hg.cs.mu.oz.au>
>>>>> "Fergus" == Fergus Henderson <fjh@cs.mu.oz.au> writes:
Fergus> On 26-Feb-2001, Nathan Sidwell <nathan@codesourcery.com>
Fergus> wrote:
>> Hi, should we take the opportunity to deprecate non-type
>> template parms of float, double or complex type in 3.0?
Fergus> Why should they be deprecated?
The arguments in favor:
- They're non-standard.
- They don't work when cross-compiling, in general, due to weakness
in the name-mangler and elsewhere.
- Their semantics are unclear. For example:
template <double d>
class C {};
template <>
class C<1.0> {};
C<1.1 - 0.1> c;
Do we get the specialization or not? The situation is much less
clear than with integer arithmetic.
The arguments against:
- This is probably not an extension that causes conforming programs to
behave differently. Any time you use a template parameter that has
`float' or `double' type, you are outside the standard so all
bets are off.
Actually, I'm not sure what the overloading rules say here, and
whether or not something like:
template <class T, T t> void f(T t);
is rejected as an overload candidate if `t' has type `float'. If it
*is* supposed to be rejected, then this extension might change
the meaning of a conforming program, meaning that is not an
extension, but a modification.
- Some other compilers do support them.
I, personally, support deprecating them. Jason, what do you think?
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com