Topic: Are there any plans (or open proposals to the C++ comittee) for
Author: nagle@animats.com (John Nagle)
Date: Mon, 29 Aug 2005 18:50:07 GMT Raw View
kevin.hall@motioneng.com wrote:
> I know that with template meta-programming, one can create functions
> that will be evaluated at compile-time. However, TMP has its
> disadvantages:
>
> (1) Templates do not support floating point numbers
>
> (2) Many compilers will only recurse a certain number of levels (10 to
> 50). Many useful calculations require possibly hundreds of levels of
> recursion (especially for floating point calculations)
>
> (3) Some experimental work has been done to support floating point
> calculations using templates
> (http://mi.eng.cam.ac.uk/~er258 /code/fp_template.html), but the speed
> is terrible -- FLOPS measuring in the single digits.
>
> Personally, I'd really love to see something provided by the language
> that would allow evaluation of all the functions in <math> at compile
> time. For example:
>
> double root_2 = // user defined variable
> meta_sqrt(2.0); // compile-time function
>
> What do you guys think?
You can already write
const double root_t = sqrt(2.0);
and it will be evaluated during program startup. You don't
get a compile-time constant, but do you really need one?
John Nagle
Animats
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]