How to call function in the way require it as inline function only on this particular call, and the function may not have inline identifier in declaration
Optimisations at both the compiler stage and linker stage can happen.
Plus the granularity will never be as fine as 'just this one call in this one place'.
Well you can create cruft by also making a #define macro version of the contents of said function, then using a macro expansion to get something looking like an inline function.
Going the other way is easier - forcing an inline function to always be called.
To do that, you just create a function pointer, and call it indirectly.
(*) Unless your toolchain is open source and you take the nuclear option of hacking your tools to do your bidding.
write the function body (no header) in its own cpp file. the variable names used in the function must be used in the calling code to match up. I recommend wrapping this block in {} pairs so any local variables in the function code are scoped.
when you need to call it inline
#include file
if you also want to use it normally, wrap that:
type foo( … params..)
{
#include file
}
this is similar to making it a macro without the macro mess. The preprocessor just injects a copy of the code where you tell it to, 'inline' and the wrapper puts it back to 'normal' by having a normal function with the code injected there too.
It is kinda hacky. But I have used this to force inline something that the compiler was being stubborn about in high performance code. I never needed the wrapper / normal calls, I needed a true forceinline that worked (even force inline is a suggestion, if you didn't know, but its a STRONG suggestion on visual). I would rename the .cpp file to a different extension if your compiler supports that. I used .inc to tell the reader it was special