This project is read-only.

Templates Refresher

The first section provides an overview of different forms of templates in C++, knowing which is vital to understanding the methods of metaprogramming
  1. Specialization
  2. Automatic type detection

Building Blocks

Here you will see some of basic techniques used in compile-time algorithms
  1. Static factorial
  2. Static assert
  3. Static condition


scheme is a functional language (a dialect of lisp), you will find some of its construcs used heavily in template metaprogramming
  1. Basic recursion
  2. List processing


Now it's time to see how we can apply list processing algorithms we've used in scheme to C++ metaprograms. We will define typelists, which, as you would expect, represents compile-time list of types, and see how we can manipulate those. Next section will show one of possible uses of typelist.
  1. Typelists basics
  2. Simple algorithms
  3. "For Each"
  4. Generating class heirarchy


In this section we'll combine all techniques presented in earlier sections, to build a minimalistic version of variant class. Variant is an extended version of union, which allows you to keep non-trivial objects, and also to choose the list of supported types (instead of having those hard-coded). Note: if you are going to use variants in real application, consider boost's implementation, as it gives much more power and safety.
  1. The interface
  2. Reserving static memory
  3. Type-specific operations
  4. Putting all together

Last edited Nov 30, 2007 at 9:25 PM by migo, version 6


No comments yet.