Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-08-12 12:14:58


on Sun Aug 12 2007, "John Maddock" <john-AT-johnmaddock.co.uk> wrote:

> As others have said already - template meta-programming is a
> different beast altogether - it generates neither code nor data

Much as I hate to disagree with John (especially since I agree with
the bulk of his post), that statement has been made twice in this
thread and it's not quite correct. I know what the posters mean:
computation with types and compile-time constants does not in and of
itself generate any code or data. I can take a program, add massive
template meta-computations that slow compilation by hours, and not
change the resulting executable image one bit.

But of course, that's pretty useless and uninteresting. The whole
point of metaprogramming is to change the executable image
programmatically, so code and data generation most certainly *is*
something one does with metaprograms (in C++, that would be e.g. by
instantiating function templates). Code generationi with metaprograms
is (or should be) done very intentionally, so you're generating
exactly the code you want.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk