inline has a double meaning that some people donโt know about - it allows you to define a function in more than one translation unit (i.e. if you define an unrelated function in the header and include it from different translation units, you are forced to declare it inline or the linker will complain double-digit characters).
The second value is a hint for the compiler that this function can benefit from embedding its machine code on the callerโs website. You are right, modern compilers / optimizers should be able to figure this out on their own.
My advice is to use inline only when necessary (the first case) and never pass the optimization hint to the compiler. Thus, this crazy double meaning is allowed in your source code.
source share