Class
LoopReverseHelper for reverse loops.
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
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
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.