W
WW
lilburne said:If the method is virtual then you will normally be calling
it via base some class, in other words you'll be using late
binding. In such cases the compiler can't inline the call
because it doesn't know which derived class version of the
method to inject. Therefore, it uses the virtual calling
mechanism so your virtual method is not inlined. Secondly
the compiler needs to have a method to call so it injects a
static version of the method into the object file created by
each source file that reads the header, you might also get a
copy of the classes vtable injected into the object file too.
Which might happen anyways, depending on the compiler you are using.
Using inlines in general is a bit like writing:
if (expression) some_statement;
Try putting a break point on some_statement. Try puting a
break point on an inline method. You might be able to step
into one but you wont be able to break when the method is
called.
Again: this is compiler/debugger dependent.
In some cases where a method is small and heavily used then
inline will give some performance benefit. But the cases
where that is so is pretty limited.
With you compiler, perhaps.0
Then there is the obsfucation of the inline methods
cluttering up the class header files.
For those who are unable to read C++, perhaps.
When inlining is
heavily used the classes API becomes obscured, and when an
inline method is altered the world has to recompile.
Yes. And when should a Clone method be altered? When the class name
changes.
If you hate inline, hate them. But starting a ranting when someone uses
inline notation in _example_ code is plain silly.