GCC has function attributes always_inline, noinline, and flatten which let you control inlining behavior when defining a function. I'm wondering if there is a way to customize inlining behavior where the function is called, rather than setting a global inlining behavior for it like the attributes normally do.
For noinline, I can wrap a call inside a lambda with the noinline attribute and call the lambda immediately. For flatten I can wrap the function inside a template function that has true/false specializations that call the underlying function, one with flatten and one without.
But for always_inline I have no such hack. Does one exist? To be clear, I'm looking to be able to say that a specific call to f()
should be inlined, not cause it to always be inlined everywhere.