Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why and when Template Metaprogramming

0 views
Skip to first unread message

Rock Johnson

unread,
Jun 10, 2005, 2:35:06 AM6/10/05
to
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?

Vyacheslav Kononenko

unread,
Jun 10, 2005, 8:50:37 AM6/10/05
to

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

Reagrds,
Vyacheslav

Rapscallion

unread,
Jun 10, 2005, 5:12:15 PM6/10/05
to

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).

red floyd

unread,
Jun 10, 2005, 5:53:31 PM6/10/05
to
Rapscallion wrote:
> [redacted]
>

We get it. You don't like templates.

PLONK.

ben

unread,
Jun 10, 2005, 8:43:57 PM6/10/05
to
> We get it. You don't like templates.
>
> PLONK.

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

ben


Rapscallion

unread,
Jun 11, 2005, 6:24:45 AM6/11/05
to
red floyd wrote:
> We get it. You don't like templates.

I don't like bloat, macro-, OO-, and template-bloat. OTOH, I like (a)
KISS.

Lionel B

unread,
Jun 13, 2005, 5:57:09 AM6/13/05
to
Rapscallion trolled (again):

> Rock Johnson wrote:
>> 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.

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.

--
Lionel B

alex goldman

unread,
Jun 13, 2005, 6:42:36 AM6/13/05
to
Lionel B wrote:

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".

Lionel B

unread,
Jun 13, 2005, 6:56:49 AM6/13/05
to
alex goldman wrote:
> Lionel B wrote:
>
>> Rapscallion trolled (again):
>>> Rock Johnson wrote:
>>>> 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.
>>
>> 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.
>>
>
> 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.

--
Lionel B

misiek3d

unread,
Jun 13, 2005, 11:03:13 AM6/13/05
to

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

0 new messages