The inline has always been a simple suggestion for the compiler. This means that if the compiler chooses this, it can ignore this sentence. In addition, if the compiler can inline a function, it can inline this function, even if you did not ask it to do so.
However, for the compiler to be able to inline the function, it must know the body of the function. If a function is defined in a separate compilation unit, then the compiler probably does not know the function definition outside this compilation unit. In this case, the compiler can only embed the function in callers in the compilation unit that defines the function. Therefore, you should take into account that if you want to allow the compiler to embed a function, you must define the function in the class definition or add the inline and define it in the header. Built-in functions do not violate ODR .
Another consideration you should make is that since inline functions should be in the header, and since headers are usually included with a number of compilation units, inline functions increase the static link. This means that changing the definition of an inline function will lead to a cascade in compilation through all dependent compilation units. This is important: defining a function does not have to be part of the interface, but built-in functions force this connection.
For this last point, in the end, I would say never a built-in function. That is, until you are annoyed enough by the speed of your application or library, at this point you should run the profiler to see if any specific functions will improve performance. Built-in functions can also reduce the size of the executable file if their attachment leads to a smaller object than the code needed to generate the function call, but this is a less important decision-making factor in most, but few (built-in?) Contexts.
The profiler can tell you that a particular function can improve performance if it is built-in, but it cannot tell you if a particular built-in function can improve performance (size, runtime, development, ...) if it is not enabled.
source share