July 26, 2011, 12:35 p.m.
posted by jackexe
New Forms of Design Patterns
The new form of static polymorphism leads to new ways of implementing design patterns. Take, for example, the bridge pattern, which plays a major role in C++ programs. One goal of using the bridge pattern is to switch between different implementations of an interface. According to [DesignPatternsGoV] this is usually done by using a pointer to refer to the actual implementation and delegating all calls to this class (see Figure).
3. Bridge pattern implemented using inheritance

However, if the type of the implementation is known at compile time, you could use the approach via templates instead (see Figure). This leads to more type safety, avoids pointers, and should be faster.
4. Bridge pattern implemented using templates

- Comment