Speeduino
Loading...
Searching...
No Matches
static_for.hpp
Go to the documentation of this file.
1#pragma once
2
16#include <stdint.h>
17
40template <uint8_t from, uint8_t to>
41struct 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)
64template <uint8_t to>
65struct 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
static TIntegral readSerialIntegralTimeout(void)
Reads an integral type, timing out if necessary.
Definition comms.cpp:173
Generate a fixed number of calls to a given free function at compile time.
Definition static_for.hpp:41
static void repeat_n(funcType f, Args...args)
Unroll, calling a free function.
Definition static_for.hpp:55