John wrote:
I want to output the stuff computed using the compiler using template
metaprogrms
(not at runtime but compile time). An easy example is to output the set
of
fibonacii numbers at compile time instead of run time. (using maybe
error messages/
warnings...? Any other way except the output code generated).
Anyone knows if this is possible to do in g++? In general c++?
Two books in the C++ in Depth Series should help: Generic Programming
and Template Metaprogramming. These two books should help you a great
deal. You could also just look at the code to BOOST_STATIC_ASSERT.
It _is_ impossible to write "portable" code (what they really mean is
standard) because in reality you are creating an ill formed program.
Different compilers will display the errors differently, as they are
free to do so, but in reality you can predictably cause certain output
to appear /somewhere/ in the error report.
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]