Unlike some people still believe, the inline
keyword in C++ does not primarily exist to tell the compiler to inline-expand a function. It exists to tell the linker that there may be multiple definitions of a function and the user promises that all definitions are the same.
But it is also related to optimization. People usually say that it is a hint to the compiler to inline a function. I remember I once looked up the inlining metrics in the LLVM source code, and I think it rates a functions inline-value (as in performance gain if the function is inline-expanded) higher if it's declared with the inline
keyword. Unfortunately I can't find it right now.
Nevertheless I think this is a strange behaviour. The one definition rule and the inline expansion optimization seem totally unrelated to each other. Why is there one keyword that controls both them both (at least to a degree)?
If the compiler knows best when to inline a function, why even take the hint from the inline
keyword? Is it for historical reasons or does it have any practical value with modern compilers?