Reputation: 151
I have read, multiple times, that all member functions defined inside a class are inlined by default. Does that mean that the compiler will always put the body code of the function on the stack if it is suitable( i.e. the code does not contain any loops or function calls)?
Upvotes: 1
Views: 279
Reputation: 145429
all member functions defined inside a class are inlined by default.
No, they are inline
by default.
That means that the definition can and must be provided in every translation unit where the functions are used. For member functions that means, where an instance of the class is used.
inline
also has a hinting effect about machine code inlining of calls. The compiler can follow or ignore that hint at its discretion, per call.
Upvotes: 8