Speeduino
Loading...
Searching...
No Matches
speeduino
static_for.hpp
Go to the documentation of this file.
1
#pragma once
2
16
#include <stdint.h>
17
40
template
<u
int
8_t from, u
int
8_t to>
41
struct
static_for
{
42
54
template
<
typename
funcType
,
typename
...Args>
55
static
inline
__attribute__
((
always_inline
))
void
repeat_n
(
funcType
f
,
Args
...args){
56
f
(
from
,
args
...);
// Call the supplied free function
57
//cppcheck-suppress misra-c2012-17.7
58
static_for<from + 1U, to>::repeat_n
(
f
,
args
...);
// Call next iteration
59
}
60
};
61
63
// The loop termination specialization for static_for<uint8_t, uint8_t> (you can ignore this)
64
template
<u
int
8_t to>
65
struct
static_for
<
to
,
to
> {
66
67
template
<
typename
funcType
,
typename
...Args>
68
//cppcheck-suppress misra-c2012-17.7
69
//cppcheck-suppress misra-c2012-8.2
70
static
inline
void
repeat_n
(
funcType
,
Args
...){
71
}
72
};
73
readSerialIntegralTimeout
static TIntegral readSerialIntegralTimeout(void)
Reads an integral type, timing out if necessary.
Definition
comms.cpp:173
static_for
Generate a fixed number of calls to a given free function at compile time.
Definition
static_for.hpp:41
static_for::repeat_n
static void repeat_n(funcType f, Args...args)
Unroll, calling a free function.
Definition
static_for.hpp:55
Generated by
1.9.8