Monday, April 26, 2010

Writing Programs that Write Programs

Have you ever wished you could write a program that would write programs for you? A program that writes other programs is called a metaprogram. Both C and C++ actually do include the ability to do certain forms of metaprogramming!

You've already seen some forms of metaprogramming in C++, using
templates to generate data structures that can handle any type.

A nifty feature called template specialization allows you to specify a different implementation of a template for a special type:
And in both C and C++, the macro processor allows you to do some basic metaprogramming (like conditionally compiling code):

Happy meta-programming!

source :
cProgramming Mail List


49 Dover St. #37, Somerville, MA 02144, USA

No comments:

Post a Comment