Angelika Langer - Training & Consulting
HOME | COURSES | TALKS | ARTICLES | GENERICS | LAMBDAS | IOSTREAMS | ABOUT | CONTACT | Twitter | Lanyrd | Linkedin
HOME 


  UPCOMING
  PREVIOUS
  MATERIALS
 
GENERICS 
LAMBDAS 
IOSTREAMS 
ABOUT 
CONTACT 
Compile-Time Computations in C++

Compile-Time Computations in C++  
 
 
ABSTRACT
 
 
Class and function templates add another dimension of programming power to the C++ language. Computation of constants, evaluation of expressions, polymorphic dispatch of functions are examples of tasks that can be solved at compile time rather than at run time - using templates. In this lecture, we explore advanced template programming techniques that can replace corresponding object oriented idioms and help eliminated the run time overhead of traditional object oriented programming. 
  • Polymorphism is one of the classic ideas of object oriented programming. In C++, it typically involves inheritance and virtual function dispatch at run time. Using templates, polymorphic behavior can be dispatched at compile time already, thus eliminating any run time overhead.
  • The strategy pattern deals with interchangeable algorithms and suggests an implementation technique that involves inheritance. The use of templates provides a run-time efficient alternative technique, sometimes referred to as policy mix-ins.
  • The C++ template instantiator is a primitive recursive function evaluator. Certain expressions and constants can be computed recursively at compile time rather than at run time.
In this lecture, we explore function templates, function pointers, function object types, traits, the typename keyword, explicit function template argument specification, function template overloading, and other advanced template features. 
 
 
PREREQUISITES

 
 
Level: intermediate
Duration: 2 hours
Prerequisites: Attendants should be familiar with the concept and pre-standard language constructs for template programming in C++. Any knowledge of recently added template features is not required.
Presented at: C++ World , New York, NY, August 1998 
Application Development '99 , London, UK, July 1999 

 
 
 

If you are interested to hear more about this and related topics you might want to check out the following seminar or skim through some further reading:
Seminar
 
C++ Template Programming
3-day seminar (open enrollment and on-site)
 
Paper
 
Compile Time Computations in C++ -
Novel Template Programming Techniques
short white paper (providing first insights)
 
Slides
 
C++ World , New York, NY, August 1998
  © Copyright 1995-2005 by Angelika Langer.  All Rights Reserved.    URL: < http://www.AngelikaLanger.com/Conferences/Abstracts/PolicyMixins.htm  last update: 12 Nov 2005