Template Specializations and Meta Programming
Explore template specializations and meta programming.
We'll cover the following...
Template specializations
We have discussed template specializations in the templates chapter. Like type parameters, other kinds of template parameters can also be specialized. The following is the general definition of a template and its specialization for 0:
Press + to interact
void foo(int value)() {// ... general definition ...}void foo(int value : 0)() {// ... special definition for zero ...}
We will take advantage of template specializations in the meta programming section below.
Meta programming
As they relate to code generation, templates are among the higher-level features of D. A template is code that generates code. Writing code that generates code is called meta programming.
Due to templates being compile-time ...