- Do modern c++11-compatible compilers always ignore inline hints specified by user and do this only automatically?
C++11 is irrelevant here, the C++11 standard did not change the semantics of inline
and compiler optimisations are largely independent of the language version being compiled.
- Do inline hints only stay to provide backward compatibility?
No, inline
is not a hint, and the compiler doesn't "ignore" inline
because if it did that you'd get multiple definition errors. The meaning the compiler gives to the inline
keyword is not the meaning you seem to understand. It's not a hint.
If the compiler can't see the function definition it can't inline it (Link-Time Optimization changes that, but use of LTO is not very widespread yet and most libraries do not ship with LTO-enabled binaries that would allow link-time inlining).
You should read inline
as "this function definition appears inline in this file" not "calls to this function should be inlined".
So the inline
keyword is useful for allowing the compiler to see function definitions in multiple files, which means it is possible for it to optimise the calls away by inlining them. That doesn't necessarily make it more likely to be inlined than any other function defined in the same translation unit.
For functions that are called from multiple translation units defining the functions in headers and making them inline
is necessary condition for the compiler to inline them, but it is not sufficient (because the compiler bases its inlining decisions on other conditions).
This has nothing to do with backwards compatibility, it is just as true today as in 2009.