Up: Typedefs


10.1 Typedef Templates

Typedefs themselves may be templated, as best illustrated by the following example:

     template <pint N, M>
     defproc matrix(bool x[N][M]) { ... }
     
     template <pint L>
     typedef matrix<1, L> row;
     
     row<3> a_row_of_length_3;
     
     template <pint H>
     typedef matrix<H, 1> col;
     
     col<3> a_col_of_height_3;
     
     template <pint N>
     typedef matrix<N, N> square;
     
     square<2> a_2x2_square_matrix;

The typedef template feature is useful for binding selected parameters of highly generalized template definitions to conveniently reduce the number of parameters.

Q: Can typedef templates be defined with default parameter values?