Summer 2003: Algorithm Library Design

Homework 5: Tuesday, 10.06.03

due Thursday , 19.06.03, 4pm
Submit homeworks to Roman Dementiev <dementiev@mpi-sb.mpg.de>. Source code only, no executables!

Exercise 5 (10 Pts)

(Source code for this exercise can be found at: list_components.h, list_generator.h, and list_example.C)

In the list generator described on the lectures, the template arguments must be given in order. For example, to specify the list of ints with defaults except for tracing, one has to write:

typedef LIST_GENERATOR<int,cp,mono,no_counter,
                           with_tracing>::RET List;
The goal of this exercise is to modify the generator to support an arbitrary order of arguments, so that we can instead write:
typedef LIST_GENERATOR<int,with_tracing>::RET List;
More precisely, in addition to the first mandatory argument, the ElementType, the generator should accept up to 4 optional arguments, at most one from each of the following categories: The optional arguments can be given in any order. Trying to give more than one arguments of the same category should cause a compilation error. The argument with_counter<LengthType> has its own optional argument specifying the LengthType. The default length type is chosen using with_counter<>.

Modify list_generator.h according to the above specification and return the modified file. Do not modify list_components.h or add any new files.

Hint: Use the named template arguments technique described on the lectures with cp, ext_ref, etc. as the setters.


Lutz Kettner (<surname>@mpi-inf.mpg.de). Last modified on Tuesday, 10-Jun-2003 13:40:38 MEST.