Two C++ Template Ideas
On this page you can find some C++ code which I wrote to try out ideas pertaining to templates.
A Class for Implementing 'Smart Properties'
This set of classes allows the declaration of a member which intercepts any setting or getting of the contained data. The main class of the framework is Property which has two formal type parameters, T and D. The parameter T is the type of the contained data, and D is an optional delegate class which provides the functions to be called when the property data is retrieved or modified. D defaults to Delegate which is intended to have specializations which perform generic getting and setting operations typical of a particular data type.
The intention of this framework is to make any required special operations when getting or setting a member transparent, relieving the outside user of the member from explicit boilerplate code. It also saves the user from the possibility of mistakenly missing out or incorrectly calling required boilerplate functions. Furthermore, the user code may be statically polymorphic if Property is used as a type parameter.
Bezier Curves with Template Metaprogramming
This set of classes can be used to evaluate points on a Bezier curve of any degree using the Bernstein polynomial method. The coefficients for the curve are pre-computed and the loops unrolled through use of templates and template specialization. The control points of the curve can be of any type so long as they support some basic arithmetic operations.