Defining the cell complex as constant within the class, it is possible to implicitly avoid writing quantity access. In the following the implementation of an accumulation function sum using the Phoenix2 library is briefly shown. In this case the function for the evaluation has to be passed a function object containing the summand function. The evaluation function can be written as follows:
eval(Env & env, Summand & sum) { base_elem = at<0>(env.args); Iterator iter(base_elem); result = 0; while (iter.valid()) { result += summand.eval(newenv(env, *iter)); ++iter; } }
The first element of the passed environment is used to construct an iterator which traverses, for instance, all incident neighboring elements of a given dimension. For the evaluation of the summand, the value of the iterator has to be passed to the evaluation function. For this reason a new environment comprising arguments and named variables is created, which contains all elements of the old environment as well as the traversed element which implicitly stands for the first argument. This means that for all function evaluations of the summand the first argument is the element passed.