..rhavin grobert wrote:
if you have
class Base {
virtual inline bool foo() {return false;};
};
class Derived: public Base {
virtual bool foo();
};
bool Derived:foo()
{
/* lot's of code here */
return true;
};
is foo() always inlined for Base?
What does that mean?
is foo always (jumped /
called / ...) (<-?) for Derived?
What does that mean?
A function cannot be "always inlined" or "never inlined". You have no
control over that - the compiler is free to do what it thinks is best,
neither do you have any way of knowing what the compiler did - there is
no portable way to determine if a particular function was ever inlined
or not. Why do you care?
The concepts of dynamic binding (virtual functions) and inlining are
orthogonal. If the compiler knows that it needs to call 'Base::foo' and
it has the implementation handy (and it's short like that), it will
*probably* (or, perhaps, *hopefully*) inline it. If the compiler needs
to involve run-time resolution (i.e. it has a pointer or a reference to
'Base' and calls 'foo' with that), it will generate code to call the
function in a particular way (v-table, etc.) and "inlining" has nothing
to do with that.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask