[C++] float, double & complex template non-type parms
Nathan Sidwell
nathan@codesourcery.com
Tue Feb 27 01:40:00 GMT 2001
Mark Mitchell wrote:
> The arguments in favor:
Another one is they're not implemented completely, for instance default
conversions (that happen for integral type template parms), don't happen
for floating ones.
template <float T> void foo () {};
template void foo<0> (); //error doesn't match
> template <class T, T t> void f(T t);
>
> is rejected as an overload candidate if `t' has type `float'. If it
It is rejected with -pedantic, accepted otherwise.
> Nathan, if you like, go ahead and prepare a deprecation patch for the
> branch, and a patch to remove them altogether on the mainline
wilco,
Wolfram Gloger wrote:
> You forgot the very important:
>
> - They enable you to write a C++ program that can compute a picture of
> the Mandelbrot set _at compile time_. With only integer arithmetic
> that is much less fun..
<chuckle> I'm sure someone skilled will find it even more fun to implement
a fixed point implementation with integral arithmetic -- after all 30 or 62
bits of binary fraction is pretty good (IIR you need 2 bits of integer for
the set) - Heck you could even do something like
template <int mantissa, int exponent> ...
probably ...
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
More information about the Gcc
mailing list