3 ms·
Sort of. If you want the instantiation model, you can go with forwarding functions (maybe preprocessor instantiated): void malloc_stack_drop(void *s) {
by JonChesterfield 2y ago
Sort of. If you want the instantiation model, you can go with forwarding functions (maybe preprocessor instantiated):
void malloc_stack_drop(void *s) {
stack_drop(&malloc_stack_global, s);
}
If you inline stack_drop into that and user code has calls into malloc_stack_drop, you get the instantiation model back.
Absolutely agreed that this is working around a lack of compiler hook. The interface I want for that is an attribute on a parameter which forces the compiler to specialise with respect to that parameter when it's a compile time constant, apply that attribute to the vtable argument. The really gnarly problem in function specialisation is the cost metric, the actual implementation is fine - so have the programmer mark functions as a good idea while trying to work out the heuristic. Going to add that to my todo list, had forgotten about it.