J
Jon Rea
http://osl.iu.edu/~tveldhui/papers/Template-Metaprograms/meta-art.html
Can anyone shed some light on the need for stuff like this when using
any of the most modern compilers?
If i have a function :
double Square( double d )
{
return d * d;
}
and use it like this:
int main()
{
double answer = Square( 4.0 );
}
I always assumed that the compiler is cleaver enough to decide that the
function call is not needed and just set 'answer' to 16 in the compiled
machine code. If that is the case, is the use of simple meta templates
irrelevent with modern compilers (esp. see 'Temporary variables' in the
example posted URL above).
I assume that more complex meta programs are still useful today when the
compiler cannot make informed choices about complex code.
Many thanks for your replies,
Jon
Can anyone shed some light on the need for stuff like this when using
any of the most modern compilers?
If i have a function :
double Square( double d )
{
return d * d;
}
and use it like this:
int main()
{
double answer = Square( 4.0 );
}
I always assumed that the compiler is cleaver enough to decide that the
function call is not needed and just set 'answer' to 16 in the compiled
machine code. If that is the case, is the use of simple meta templates
irrelevent with modern compilers (esp. see 'Temporary variables' in the
example posted URL above).
I assume that more complex meta programs are still useful today when the
compiler cannot make informed choices about complex code.
Many thanks for your replies,
Jon