The code of the function
B::Foo()
can be inlined at the place where this function is called if the compiler can unambiguously determine that this function will be called at this place, regardless of context. For example:
void test(B *b) {
// this call can be inlined, because it's obvious that B::Foo()
// will be called in any case, regardless of context.
b->Foo();
}
The code of the function
B::Foo()
cannot be inlined in cases where the compiler cannot unambiguously determine that the function
B::Foo()
will be called in this place. For example:
void test(A *a) {
// this call cannot be inlined, because virtual method pointer A::Foo()
// can point to any of the methods X::Foo(), where X is a descendant of class A,
// i.e. the call to a particular method depends on the context (pointer to a virtual function A::Foo()).
a->Foo();
}
Ввійдіть щоб вподобати
Ввійдіть щоб прокоментувати