Frans Englich wrote:
> On Monday 10 October 2005 22:29, Mark Mitchell wrote:
>
>>Frans Englich wrote:
>>
>>>Followup question: what is the increased cost of calling a non-virtual,
>>>inlined function('inline' keyword) on a virtual base?
>>
>>None, if the function is inlined -- and whether it is inlined or not
>>should not be affected by whether or not it is in a virtual base.
>
>
> Ok, let me check my understanding of Joe's and your's reply, by an example:
>
> //----------------------------------------------
> class Shared {
> public:
> // ....
> inline void ref() { m_ref++; }
> // ...
> protected:
> unsigned int m_ref;
> };
>
> class B : public virtual Shared {};
> class C : public virtual Shared {};
> class BC : public B, public C {};
> //----------------------------------------------
>
> Running the expression "BCinstance->ref()" leads to the penalty that
> accessing
> the "m_ref" variable requires an indirection, if I've understood correctly.
Yes.
> What can safely be concluded from that? For example, could register
> allocation
> make it uncertain exactly how much the indirection costs?
Yes. (There are even scenarios where the indirection could actually
help, rather than hurt.) You'll just have to measure.
--
Mark Mitchell
CodeSourcery, LLC
[EMAIL PROTECTED]
(916) 791-8304