# 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

- `LoopReverse::run(arg, i);`
  Run the loop body.

## Detailed Description

### Example

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(Nothing & arg, int I)
        {
            (void)arg;  // ignored
            printf("%d\n", I);
        }

    };

Snippet from: demos/dox/basic/metaprogramming_control.cpp

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.

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

Snippet from: demos/dox/basic/metaprogramming_control.cpp

## See Also

- Loop

## Member Functions Detail

### `LoopReverse::run(arg, i);`

Run the loop body.

#### Parameters

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

#### Data Races

Thread safety unknown!

#### Dox Sources

    /*!
     * @class LoopReverse
     *
     * @headerfile <seqan/basic.h>
     *
     * @brief Helper for reverse loops.
     *
     * @signature template <typename TWorker, unsigned COUNT> struct LoopReverse;
     *
     * @tparam TWorker A struct with a static inline void function called
     *                 <tt>body</tt>. <tt>body</tt> 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 <tt>COUNT</tt>
     *                 times with the same reference for the first one and the
     *                 values <tt>COUNT</tt>, <tt>COUNT - 1</tt>, ..., <tt>1</tt>
     *                 for the second parameter.
     * @tparam COUNT An <tt>int</tt> constant.
     *
     * @section Example
     *
     * We define the following worker to print an integer. The first argument is of
     * <tt>Nothing</tt> as a dummy. Note that the parameter is not const.
     *
     * @snippet demos/dox/basic/metaprogramming_control.cpp print worker
     *
     * The following shows an example calling <tt>PrintWorker::body()</tt> 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.
     *
     * @snippet demos/dox/basic/metaprogramming_control.cpp print worker call loop
     *
     * @see Loop
     *
     * @fn LoopReverse::run
     *
     * @brief Run the loop body.
     *
     * @signature LoopReverse::run(arg, i);
     *
     * @param[in,out] arg The argument to pass to the worker's <tt>body()</tt>
     *                    function.
     * @param[in] i The <tt>int</tt> passed to the <tt>body()</tt> function.
     */