[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost
Subject:    Re: [boost] [pimpl] Proposal. Determining interest.
From:       Vladimir.Batov () wrsa ! com ! au
Date:       2007-11-01 20:12:05
Message-ID: OFD730C389.39C7A332-ONCA257386.006DA03A-CA257386.006EF272 () wrsl ! com
[Download RAW message or body]

>> Inherited Pimpls 
>>
>> sdfsd 
>>
>> 
>> Polymorphic Implementations 
>> 
>> sdfs

>I'd very much like to see those sections, or even only how you'd go about 

>re-using a pimpl_ptr from a base class, inheriting Derived::Impl from 
>Base::Impl.?

It has to be remembered that Pimpl idiom is about implementation hiding, 
i.e. it's about implementation and it's about hiding. It's not about 
making a class to behave as a pointer -- that is done by shared_ptr and 
done beautifully. A Pimpl-based class is by all means an ordinary class. 
The fact that its implementation is done in pimpl fashion is an 
implementation detail and is irrelevant when one inherits from that class. 
Therefore, as far as inheriting from a Pimpl-based class is concerned, 
there is not much to it.  That is,

class Test : public pimpl<Test>::pointer_semantics
{
};

>From outside Test is an ordinary C++ class and NOT a pointer or anything 
like, say, shared_ptr<Test>. So, to inherit from it

class Derived : public Test
{
};

Certainly it is unreasonable to expect all the perks that pimpl<> provided 
while we built Test to percolate to Derived.

As far as "inheriting Derived::Impl from Base::Impl", then I've been doing 


pimpl<Base>::implementation
{
}; 

pimpl<Derived>::implementation : pimpl<Base>::implementation
{
}; 

on one occasion. So far, my experience is that you cannot make much use of 
it (like Test being polymorphic and housing Derived implementation 
instead)... unless you are prepared to forgo implementation hiding -- 
something the Pimpl is deployed for in the first place. If you do not care 
for implementation hiding, then I'd suggest going with shared_ptr instead.


Thanks,
Vladimir.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic