#How to obtain a pointer to instantiated generic function?

1 messages · Page 1 of 1 (latest)

balmy ginkgo
#

Suppose I have the following two functions:

// For each comptime-known b generates a "fn(i32) i32"
fn genericComptime(a: i32, comptime b: i32) i32 {
    return a + b;
}

// For each runtime-known a:i32 also generates a "fn(i32) i32"
fn genericAny(a: anytype) i32 {
    return a + 1;
}

I want to obtain *const fn(i32) i32 pointers to their instantiated versions mentioned in the comments. Is the only way to achieve that by using wrappers? (Besides the boilerplate, I'm also a bit unhappy that this may potentially generate redundant call instructions - unless I use @call(.always_inline...) in the wrappers).

orchid gulch