Monday, February 27, 2012

Summary

A short summary.

So far, I have introduced templates programming step by step with some examples. I didn't explain many things by myself, I tried to show you how it works.

Bearing all of this in mind, it's time to go over the profits of templates and the reason of being so interesant.


  • Templates are type-safe: The compiler is able to do the type checking before a error occurs.
If you write general code for a common base class you lose this benefits. Moreover  is expected you may derive this class, which makes it even more difficult to maintain.
  • Easiness writing them: With just one class we may have an infinity number of uses
Remember the example of max, with which one we saved many definitions. 
  • Optimize the runtime by compiling time: This point, I'd like to flesh out through metaprogramming but stay with the idea.
  • Good possibility to reuse code.


No comments:

Post a Comment