Possible Duplicate:
Inline functions in C++
Modern compilers are better than programmers at deciding what should be inlined and what should not. Just like, register, shouldn’t inlining functions be a job for the compiler only, and be considered premature optimization ?
inlinehas a double meaning that some are unaware of – it allows a function to be defined in more than one translation unit (i.e. if you define an unbound function in a header and include it from within various translation units, you are forced to declare it inline or the linker would complain about doubly defined symbols).The second meaning is a hint to the compiler that this function may profit from inlining its machine code at the caller site. You’re right, modern compilers/optimizers should be able to figure this out on his own.
My advice is to use
inlineonly when it is needed (first case) and never to pass an optimization hint to the compiler. This way, this crazy double meaning is resolved in your source code.