CoDiPack  3.0.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::CompileTimeLoop< T_pos, T_end, T_step > Struct Template Reference

Compile time loop evaluation. More...

#include <compileTimeLoop.hpp>

Inheritance diagram for codi::CompileTimeLoop< T_pos, T_end, T_step >:

Static Public Member Functions

template<typename Func, typename... Args>
static inlinevoid eval (Func &&func, Args &&... args)
 Func is evaluated with args as func(pos, args...)
 

Static Public Attributes

static size_t constexpr end = T_end
 See CompileTimeLoop.
 
static size_t constexpr pos = T_pos
 See CompileTimeLoop.
 
static int constexpr step = T_step
 See CompileTimeLoop.
 

Detailed Description

template<size_t T_pos, size_t T_end, int T_step>
struct codi::CompileTimeLoop< T_pos, T_end, T_step >

Compile time loop evaluation.

step is added to pos until end is reached.

Be careful if step not -1 or 1, the end position needs to be reached directly.

Example:

int a[10];
// Via lambda:
CompileTimeLoop<0,10,1>::eval([&] (auto i) { a[i.value] = i.value; });
// Via functor:
struct SetEntry {
int* vec;
template<size_t pos>
void operator()(std::integral_constant<size_t, pos>, Type& v, Derivative const& d) {
vec[pos] = pos;
}
};
static inlinevoid eval(Func &&func, Args &&... args)
Func is evaluated with args as func(pos, args...)
Definition compileTimeLoop.hpp:86

Called range is: [pos, end)

Template Parameters
T_posStart value for the loop.
T_endEnd value for the loop.
T_stepStep value for increment or decrement.

The documentation for this struct was generated from the following file: