I have a doubt regarding inline functions. Inline functions will not involve any function calls but just replacement of function definition wherever the call is made to the inline function.Inline functions have type enforcement unlike macros. What will happen if recursive functions are made inline?
Recursive function declared as inline creates the burden on the compilers execution.
When a function is recursive, it cannot be inlined. A function containing static variables cannot be made an inline function.
Inline functions behave like macros. When an inline function gets called, instead of transferring the control to the function, the call gets substituted with the function code. Thus this saves time and improves performance.
C++ Inline functions cannot work if the function defined is recursive in nature.
"inline" isn't a guarantee, it's a request.
Your recursive inline function won't (typically) be inline.
inline
is merely a suggestion to the compiler and does not guarantee that a function will be inlined.
Obviously, the compiler won't be able to inline a recursive function infinitely. It may not inline it at all or it may inline it just a few levels deep.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With