In C++, do functions only get inlined if they are explicitly declared inline
(or defined in a header file), or are compilers allowed to inline functions as they see fit?
Yes, the compiler can inline code even if it's not explicitly declared as inline
.
Basically, as long as the semantics are not changed, the compiler can virtually do anything it wants to the generated code. The standard does not force anything special on the generated code.