Why and when Template Metaprogramming

R

Rock Johnson

I understand that template metaprogramming is a technique that allows for
calcualations to occur at compile-time rather than run-time.

Can someone explain what is the benefit of this, and when it is good to
employ Template Metaprogramming?
 
V

Vyacheslav Kononenko

Rock said:
I understand that template metaprogramming is a technique that allows for
calcualations to occur at compile-time rather than run-time.

Can someone explain what is the benefit of this, and when it is good to
employ Template Metaprogramming?

I think there is a good answer for this in Alexanrescu's "Modern C++
Design".

Reagrds,
Vyacheslav
 
R

Rapscallion

Rock said:
I understand that template metaprogramming is a technique that allows for
calcualations to occur at compile-time rather than run-time.

Can someone explain what is the benefit of this, and when it is good to
employ Template Metaprogramming?

TMP is most useful when you want to impress others and show them how
smart and clever you are. No practical use of TMP is known yet (not
even at Boost).
 
B

ben

We get it. You don't like templates.

As for me, I like templates. But if I have a choice between two solutions, I
prefer the more flexible and explicit one.

ben
 
L

Lionel B

Rapscallion trolled (again):
TMP is most useful when you want to impress others and show them how
smart and clever you are.

Ok, ok, we know (and don't care) that you don't like templates - you've been serial-trolling this ng long enough that we
get the point.
No practical use of TMP is known yet (not
even at Boost).

Not so; here's one:

http://www.oonumerics.org/blitz/

It is big and it is clever.
 
A

alex goldman

Lionel said:
Rapscallion trolled (again):

Ok, ok, we know (and don't care) that you don't like templates - you've
been serial-trolling this ng long enough that we get the point.


Not so; here's one:

http://www.oonumerics.org/blitz/

It is big and it is clever.

Have you ever used that beast? I have. It makes your life a lot easier. You
come to work, make changes to your program, type 'make' and you are free
for the rest of the day. If the boss asks, "it's compiling".
 
L

Lionel B

alex said:
Have you ever used that beast? I have.

Yup, some while ago.
It makes your life a lot
easier. You come to work, make changes to your program, type 'make'
and you are free for the rest of the day. If the boss asks, "it's
compiling".

:)

Don't know what compiler you use... it's not quite so bad as I remember it.
 
M

misiek3d

Rock said:
I understand that template metaprogramming is a technique that allows for
calcualations to occur at compile-time rather than run-time.

Can someone explain what is the benefit of this, and when it is good to
employ Template Metaprogramming?

Hi.
In game development it's sometimes useful to have consts for some sin,
cos and other values. And speed is of course highest priority. If you
don't want to use paper math tables you can write your own trigonometric
functions as meta templates and use any const value you want. It will
calculate at compile time. It may be useful :)

misiek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top