With modern compilers, does the inline function declare any performance impact anymore?
That is, when faced with the option to define the inline function in the header or in the source file, is there a difference between the two?
In this SO question When to use a built-in function and when not to use it? The accepted answer gives several reasons.
Exposure:
to do:
- very small functions are good candidates for
inline : faster code and smaller executables (more likely to stay in the code cache) - the function is very small and very often
not
- large functions: leads to large executable files, which significantly degrades performance regardless of the faster execution that occurs due to overhead
Advice from 7 years ago, and I read that these days the embedded word is ignored, and the compiler decides what to do in the line.
Questions:
- Is the above advice still relevant?
- To what extent does the definition of an inline function have any effect (other than preventing multiple problems with definition builders)?
- What are the reasons why I have to embed a function these days?
c ++ inline
Steve lorimer
source share