Is it possible to have a function take a comptime array/slice of functions (body, not pointer, with the same signature)? I am trying to get an arbitrary array of predicates unrolled at comptime where the predicate array size is known at comptime (rather than an array of function pointers). I specify the array size at the callsite but I'm getting an "unable to infer array size" error. This is a roughly distilled example of my current attempt. Thanks!
pub const predicate_t: type = fn (*std.ArrayList(u32)) u32;
// ...
pub fn apply_predicates(
comptime predicates: [_]predicate_t, // ...
) u32 {
// ...
var result: u32 = 0;
inline for (predicates) |p| {
result += p(some_arg);
}
return result;
}
// call like:
_ = apply_predicates([2]predicate_t{predicate1, predicate2});