added REPEAT_FOR_TYPES

This commit is contained in:
Patrick 2024-07-23 00:39:28 +02:00
parent 1fe0db9247
commit b10b6049c8
1 changed files with 13 additions and 0 deletions

View File

@ -253,6 +253,19 @@ inline std::ostream& operator<<(std::ostream& os, ReturnCode rc) {
}
}
template <typename ...Ts>
constexpr auto _repeat_for_types(auto f) {
std::array<ret_val_s, sizeof...(Ts)> rets { (f.template operator()<Ts>())... };
return rets;
}
#define REPEAT_FOR_TYPES(func, ...) { \
auto r = _repeat_for_types<__VA_ARGS__>(func); \
auto it = std::ranges::find_if(r, [](auto&& e) { return e.val == ReturnCode::FAILED; }); \
if (it != std::ranges::end(r)) { \
return *it; \
} \
}
#define CREATE_FROM_IL(type, il, len) \