Template libraries such as the STL contain several generic algorithms that expect functions as arguments and thereby cause frequent use of function objects. User-defined function objects are awkward because they must be declared as a class in namespace scope before they may be used. We show that, by using expression templates, the lambda function can be implemented without hurting the runtime performance of a program. Expression templates can also help to overcome the performance penalties that may arise when using expressions over user-defined types. Thus, we based our approach on PETE which is a framework that simplifies the addition of expression template functionality to user-defined classes.
Static interfaces are especially useful as constraints on template parameters.
Foo, for some static interface named Foo. We demonstrate two key utilities of static interfaces. First, constraints enable better error messages with template code. We show examples of the improvement of error messages when constraints are applied to STL code. Second, constraints enable automatic compile-time dispatch of different implementations of class or function templates based on the named conformance properties of the template types.