If you want to hint that a function should be inlined, put inline (or, for a member function, define it within its class).
No. If you are defining the function in line with the declaration, put inline in front of it. That is all that inline means in C++: two compilation units may have definitions of this because it is defined in line. That’s really critical to understanding this, the inline keyword has nothing to do with the inlining optimisation in the compiler, except that having a definition of a function visible at the call site is a prerequisite.
No. If you are defining the function in line with the declaration, put inline in front of it. That is all that
inline
means in C++: two compilation units may have definitions of this because it is defined in line. That’s really critical to understanding this, theinline
keyword has nothing to do with the inlining optimisation in the compiler, except that having a definition of a function visible at the call site is a prerequisite.