Traits and policy classes are often used with C++ generics, but their role and purpose is often something of an enigma even to experienced C++ programmers. The definitions of these two terms overlap to some extent, and could be summarized as follows:
- Traits represent natural additional properties of a template parameter.
- Policies represent configurable behavior for generic functions and types.
In this article the example code will show use of both of these two, with type information obtained through a (specialized) traits class and functionality obtained from a (generic) policy class.
Continue reading “Designing Traits and Policy Classes”