In C++, the inline
keyword really only has one required meaning: that the One-Definition Rule is suspended for that function (e.g., the function can be defined in several translation units, and the code still conforms).
Specifically, using the inline
keyword does not ensure that the code for that function will be generated inline. Defining a function inside a class definition also makes it an inline function -- but, again, that doesn't ensure that its code will be generated inline either.
Conversely, a function that is defined outside a class definition, without the inline
keyword can and may still have its code generated inline. The only difference is that in this case multiple definitions of the function renders the code non-conforming.
The bottom line is that portable code cannot assure that code either is or is not generated inline. If you don't mind making your code non-portable, however, you can use __attribute__(noinline)
.
I would not, however, do this on the basis of the cited quote from Wikipedia. Wikipedia is hardly an authoritative source, and even if it was, what you're quoting is just a vague statement about what could happen with some hypothetical language on some hypothetical compiler under some hypothetical conditions. You're generally better off writing your code to be clear and readable, and letting the compiler worry about generating good results from that.