Template Constraints Are So 1997; Usher in C++09 Concepts

Puzzled by indecipherable template compilation errors? Still struggling in vein to enforce restrictions on template parameters? It's time you migrated C++09 concepts!

by Danny Kalev

Dec 13, 2007

Page 1 of 3

++03 has a very limited set of tools for enforcing constraints on templates. Consequently, templates code becomes messy, unintelligible, and buggy. With the addition of concepts to C++09, this unsavory state of affairs is about to change radically. Learn what concepts are and they can simplify template design and implementation.

You're designing a template, but can't find a simple and consistent way to specify usage policies and enforce constraints. Consequently, your template code becomes cluttered up and bug-prone.

Use concepts to enforce usage policies on templates. This will also allow the compiler catch usage violations earlier, and issue clearer diagnostics.