What are Inline Functions ? When are Inline Functions used ?

 
 

The idea behind inline functions is to insert the code of a called function at the point where the function is called. It is useful to distinguish between "inline," a keyword qualifier that is simply a request to the compiler, and "inlined," which refers to actual inline expansion of the function. A function can be decorated with the inline keyword either in the class definition or in its own definition if the definition physically occurs before the function is invoked. The compiler does not promise that an inline function will be inlined, and the details of when/when not are compiler-dependent. On the other hand, any function that is defined within the class body will be treated implicitly as an inline function with or without the explicit inline keyword. Inline code is faster than a function call for two reasons. First, a CALL instruction takes time to execute. Second, if there are arguments to pass, these have to be placed on the stack, which also takes time