When compiling a Visual C++ project with the optimization option /Ob1, only functions with the keywords __inline / inline or those who are defined inside a class defintion get inlined (and even then not necessarily, but only if the compiler sees it fit).
My question is, is it possible to tell the compiler (under visual C++) to inline only functions that are defined inline with the inline keyword and not to inline methods defined inside class definitions, under /Ob1 optimization option?
Does the g++ compiler do the same as the /Ob1 option on Windows (let’s say, under the g++ -O3 option), does it inline member methods defined inside a class defintion? If yes, is there a way to tell it to inline only functions outside class definitions that carry the inline keyword?
The C++ standard (§ 7.1.2/3) specifies that functions that are defined inside the class definition are implicitly declared inline, basically because they need to be, to not disobey the One Definition Rule. So what you are asking for is basically an option to not inline functions that are declared inline (implicitly).
If you don’t want a function to be declared inline (for whatever reason), you should not define it in the class definition.