Class LoopReverse
Helper for reverse loops.

Defined in <seqan/basic.h>
Signature template <typename TWorker, unsigned COUNT> struct LoopReverse;

Template Parameters

TWorker A struct with a static inline void function called body. body should have two parameters, one for passing in values and state from the outside and the second is an int. The function will be called COUNT times with the same reference for the first one and the values COUNT, COUNT - 1, ..., 1 for the second parameter.
COUNT An int constant.

Member Function Overview

Detailed Description


We define the following worker to print an integer. The first argument is of Nothing as a dummy. Note that the parameter is not const.

struct PrintWorker
    static inline void body(seqan::Nothing & arg, int I)
        (void)arg;  // ignored
        printf("%d\n", I);

The following shows an example calling PrintWorker::body() through LoopReverse. We have to create a local variable since the first parameter is not const. The reason for this is that the parameter can also be used for a mutable object that holds some state.

    seqan::Nothing nothing;
    seqan::Loop<PrintWorker, 10>::run(nothing);
    // This will print the numbers 1, 2, ..., 9, 10.

See Also

Member Functions Detail

LoopReverse::run(arg, i);

Run the loop body.


arg The argument to pass to the worker's body() function.
i The int passed to the body() function.